How can I properly structure a nested asynchronous function in Typescript to return a promise of an object?
- Is it necessary for both functions to include a "catch" block to return a Promise.reject() or is one catch block sufficient?
- Despite my attempts, I keep encountering the error message "A function whose declared type is neither 'void' nor 'any' must return a value" due to the absence of a return statement outside of the functions. Even enclosing everything in a try-catch block does not resolve this issue.
async getContactByGUIDQuery(GUID: string): Promise<Contact> {
this.findContactByGUID(GUID).then(async (query) => {
this.querySalesforce(query).then(async (response) => {
return response.compositeResponse[0].body
}).catch((err) => {
return Promise.reject(err)
})
}).catch((err) => {
return Promise.reject(err)
})
}