Why do I keep getting Promise<Pending>
when using API?
Use await
or then
when using API.
If you do not use await
or then
with api
, quoteAPI
, or other API’s, they will not yield any results, as all parameters within Interceptor Methods are Promises.
Incorrect
export const quotesDetailSubmitPre = async ({ api: { crmManager } }) => { const payload = crmManager.getPayload() console.log(payload) // returns {Promise pending} }
Correct
export const quotesDetailSubmitPre = async ({ api: { crmManager } }) => { const payload = await crmManager.getPayload() console.log(payload) // returns {id: '123', name: 'pricefx Pivo a Párek' ...} }