Reputation:
Trying to log rs which should be the value of the function create order but it returns promise pending
let createOrder = async function () {
let response = await client.execute(request);
return response
};
let rs = createOrder().then((result) => console.log(result))
console.log("rsssss",rs)
Upvotes: 0
Views: 7687
Reputation: 2338
You are not following the correct code pattern to handle async/Promises. When you're chaining methods, the promise is resolved inside the callback, not outside.
The return of .then()
method is a promise object.
The correct code is this:
let createOrder = async function () {
let response = await client.execute(request);
return response
};
createOrder().then((result)=> {
//the promise is resolved here
console.log(result)
}).catch(console.error.bind(console))
Upvotes: 1