Attempt to have code wait for request to finish

This commit is contained in:
Joel Male
2020-08-26 10:34:42 +10:00
parent cfebc00721
commit db36b9f178
9 changed files with 11 additions and 8 deletions
+3 -2
View File
@@ -2,8 +2,9 @@ const fetch = require('node-fetch');
class Http {
make(url: string, headers: string, body: string): Promise<any> {
return new Promise(() => {
fetch(url, this.getOptions('post', headers, body));
return new Promise((resolve, reject) => {
fetch(url, this.getOptions('post', headers, body))
.then((res: Response) => resolve(res));
});
}