...
Code Block | ||
---|---|---|
| ||
const fetchData = async (crmManager) => { const response = await crmManager.getPayload(); console.log(fetchDataresponse); } fetchData(); // object with data from CRM { name: 'Zalgiris', id: '19860815', ... } |
Without await
, you would get unfulfilled
promise which doesn't have anything to return or show:
Code Block | ||
---|---|---|
| ||
const fetchData = (crmManager) => { const response = crmManager.getPayload(); console.log(fetchDataresponse); } fetchData(); // Promise<Pending> // This happened because console.log accessed response // while it is still being executed |
Then
then
is a method used to handle the resolution or rejection of a Promise by providing callback functions to be executed when the Promise is resolved or rejected, allowing for the chaining of asynchronous operations.
...