babel / kneden

Transpile ES2017 async/await to vanilla ES6 Promise chains: a Babel plugin
ISC License
514 stars 41 forks source link

Return not working. #50

Closed DylanPiercey closed 8 years ago

DylanPiercey commented 8 years ago
async ({ api }, user)=> {
    const userId = _.get(user, "_id");
    if (!userId) return; // This line is the issue.
    const res = await api(`user/${userId}`);
    return await res.json();
}

Becomes:

function (_ref, user) {
    var api, userId, res, data;
    return Promise.resolve().then(function () {
        api = _ref.api;
        userId = _.get(user, "_id");

        if (!!userId) {
            return Promise.resolve().then(function () {
                return api("user/" + userId);
            }).then(function (_resp) {
                res = _resp;
                return res.json();
            }).then(function (_resp) {
                data = _resp;

                return data;
            });
        }
    }).then(function () {});
}

This is ignoring the return value.

marten-de-vries commented 8 years ago

Thanks for your report. This seems a duplicate of #21. You could try to confirm that by running your example with the possible fix for that one in #43.

DylanPiercey commented 8 years ago

@marten-de-vries Looks to be the same issue. Sorry for the duplicate!

marten-de-vries commented 8 years ago

Thanks for confirming!