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

5
dist/http.js vendored
View File

@ -7,8 +7,9 @@ var Http = (function () {
}
Http.prototype.make = function (url, headers, body) {
var _this = this;
return new Promise(function () {
fetch(url, _this.getOptions('post', headers, body));
return new Promise(function (resolve, reject) {
fetch(url, _this.getOptions('post', headers, body))
.then(function (res) { return resolve(res); });
});
};
Http.prototype.getOptions = function (method, headers, body) {

2
dist/http.js.map vendored
View File

@ -1 +1 @@
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";;;AAAA,IAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAEpC;IAAA;IAqBA,CAAC;IApBC,mBAAI,GAAJ,UAAK,GAAW,EAAE,OAAe,EAAE,IAAY;QAA/C,iBAIC;QAHC,OAAO,IAAI,OAAO,CAAC;YACjB,KAAK,CAAC,GAAG,EAAE,KAAI,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACL,CAAC;IAED,yBAAU,GAAV,UAAW,MAAc,EAAE,OAAe,EAAE,IAAY;QACtD,IAAM,OAAO,GAAQ;YACnB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;YAC5B,MAAM,QAAA;SACP,CAAC;QAGF,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAGpC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAC;QAErD,OAAO,OAAO,CAAC;IACjB,CAAC;IACH,WAAC;AAAD,CAAC,AArBD,IAqBC;AAEY,QAAA,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC"}
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";;;AAAA,IAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAEpC;IAAA;IAsBA,CAAC;IArBC,mBAAI,GAAJ,UAAK,GAAW,EAAE,OAAe,EAAE,IAAY;QAA/C,iBAKC;QAJC,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YACjC,KAAK,CAAC,GAAG,EAAE,KAAI,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;iBAC/C,IAAI,CAAC,UAAC,GAAa,IAAK,OAAA,OAAO,CAAC,GAAG,CAAC,EAAZ,CAAY,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,yBAAU,GAAV,UAAW,MAAc,EAAE,OAAe,EAAE,IAAY;QACtD,IAAM,OAAO,GAAQ;YACnB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;YAC5B,MAAM,QAAA;SACP,CAAC;QAGF,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAGpC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAC;QAErD,OAAO,OAAO,CAAC;IACjB,CAAC;IACH,WAAC;AAAD,CAAC,AAtBD,IAsBC;AAEY,QAAA,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC"}

5
dist/index.js vendored
View File

@ -305,8 +305,9 @@ var Http = (function () {
}
Http.prototype.make = function (url, headers, body) {
var _this = this;
return new Promise(function () {
fetch(url, _this.getOptions('post', headers, body));
return new Promise(function (resolve, reject) {
fetch(url, _this.getOptions('post', headers, body))
.then(function (res) { return resolve(res); });
});
};
Http.prototype.getOptions = function (method, headers, body) {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

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));
});
}