I'm trying to invoke a Lambda function and return a Promise on finish,
but i get the following error:
"createUser(...).then is not a function"
const createUser = (phone) => {
return lambda.invoke({
FunctionName: 'createUser',
Payload: JSON.stringify({"phone": phone})
}, (err, data) => {
let payload = JSON.parse(data.Payload);
if (payload.statusCode != 200) {
Promise.reject(payload);
}
Promise.resolve(payload);
})
}
createUser('')
.then(res => console.log(res))
.catch(err => console.log(err))
Already tried declaring a new Promise using the
let promise = new Promise((resolve, reject) => {...})
but that didn't work also...