December 2019
Intermediate to advanced
598 pages
12h 21m
English
We are going to change the implementation for posting an answer to use the access token and our generic http function. Let's revise the implementation of the postAnswer function to the following:
export const postAnswer = async ( answer: PostAnswerData,): Promise<AnswerData | undefined> => { const accessToken = await getAccessToken(); try { const result = await http<PostAnswerData, AnswerData>({ path: '/questions/answer', method: 'post', body: answer, accessToken, }); if (result.ok) { return result.parsedBody; } else { return undefined; } } catch (ex) { console.error(ex); return undefined; }};
This follows the same pattern as the postQuestion function, getting the access token from Auth0 and making the HTTP ...
Read now
Unlock full access