0
Ich habe folgende Hilfsmethode undefined:Ausbeute mit promisified readfile Zurückgeben
module.exports.rootUrl = co(function*() {
const jsonPath = path.resolve(process.cwd(), './server/config.json');
console.log(jsonPath);
let config;
try {
const readFile = Promise.promisify(fs.readFile);
const config = yield readFile(jsonPath, 'utf-8');
} catch (err) {
console.dir(err);
yield Promise.reject(err);
};
console.dir(config);
const url = `http://${config.host}:${config.port}/${config.restApiRoot}`;
console.log(url);
yield Promise.resolve(url);
})
Das Problem ist, dass der Aufruf von yield. readFile(jsonPath, 'utf-8')
undefiniert zurückkehrt.