Here are the two methods I have written in Typescript:
async getCertURL(pol: string): Promise<string> {
return await Api.getData(this.apiUrl + pol + this.certEndpoint, {timeout: 60000}).then(
(response) => {
return response.data.certURL;
})
.catch((err) =>
this.loggingService.logError('Error generating reissue cert forward URL ' + err));
}
async getCert(pol: string): Promise<string> {
return Api.getData(await this.getCertURL(policy), {timeout: 60000}).then(
(response) => {
return response.data;
})
.catch((err) =>
this.loggingService.logError('Error cert not reissued ' + err));
}
In my getCert()
method, I tried using an await
before await this.getCertURL(policy)
to avoid needing one at Api.getData()
in getCertURL
. However, getCert()
throws an exception without it.
Should I include the await
as I did, or is there a different approach I should be taking?