aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-06-05 08:02:10 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-06-05 08:02:10 +0800
commitcf733630162e95ff5edea3b45fba5b16001f3c87 (patch)
treeaeb95b0ba55e990b0c4a0dce322cc6ba5ef875eb /packages/website/ts/utils
parenta74597c7cd44d3138de39ec05079e9b9e005d03d (diff)
downloaddexon-sol-tools-cf733630162e95ff5edea3b45fba5b16001f3c87.tar
dexon-sol-tools-cf733630162e95ff5edea3b45fba5b16001f3c87.tar.gz
dexon-sol-tools-cf733630162e95ff5edea3b45fba5b16001f3c87.tar.bz2
dexon-sol-tools-cf733630162e95ff5edea3b45fba5b16001f3c87.tar.lz
dexon-sol-tools-cf733630162e95ff5edea3b45fba5b16001f3c87.tar.xz
dexon-sol-tools-cf733630162e95ff5edea3b45fba5b16001f3c87.tar.zst
dexon-sol-tools-cf733630162e95ff5edea3b45fba5b16001f3c87.zip
Address PR feedback
Diffstat (limited to 'packages/website/ts/utils')
-rw-r--r--packages/website/ts/utils/fetch_utils.ts22
-rw-r--r--packages/website/ts/utils/utils.ts3
2 files changed, 14 insertions, 11 deletions
diff --git a/packages/website/ts/utils/fetch_utils.ts b/packages/website/ts/utils/fetch_utils.ts
index e65ac64e1..513f7e479 100644
--- a/packages/website/ts/utils/fetch_utils.ts
+++ b/packages/website/ts/utils/fetch_utils.ts
@@ -4,23 +4,26 @@ import * as queryString from 'query-string';
import { errorReporter } from 'ts/utils/error_reporter';
+const logErrorIfPresent = (response: Response, requestedURL: string) => {
+ if (response.status !== 200) {
+ const errorText = `Error requesting url: ${requestedURL}, ${response.status}: ${response.statusText}`;
+ logUtils.log(errorText);
+ const error = Error(errorText);
+ // tslint:disable-next-line:no-floating-promises
+ errorReporter.reportAsync(error);
+ throw error;
+ }
+};
+
export const fetchUtils = {
async requestAsync(baseUrl: string, path: string, queryParams?: object): Promise<any> {
const query = queryStringFromQueryParams(queryParams);
const url = `${baseUrl}${path}${query}`;
const response = await fetch(url);
- if (response.status !== 200) {
- const errorText = `Error requesting url: ${url}, ${response.status}: ${response.statusText}`;
- logUtils.log(errorText);
- const error = Error(errorText);
- // tslint:disable-next-line:no-floating-promises
- errorReporter.reportAsync(error);
- throw error;
- }
+ logErrorIfPresent(response, url);
const result = await response.json();
return result;
},
-
async postAsync(baseUrl: string, path: string, body: object): Promise<Response> {
const url = `${baseUrl}${path}`;
const response = await fetch(url, {
@@ -30,6 +33,7 @@ export const fetchUtils = {
},
body: JSON.stringify(body),
});
+ logErrorIfPresent(response, url);
return response;
},
};
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index 10381845b..b9d962b75 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -306,8 +306,7 @@ export const utils = {
return parsedProviderName;
},
getBackendBaseUrl(): string {
- return 'http://localhost:3000';
- // return isDogfood() ? configs.BACKEND_BASE_STAGING_URL : configs.BACKEND_BASE_PROD_URL;
+ return isDogfood() ? configs.BACKEND_BASE_STAGING_URL : configs.BACKEND_BASE_PROD_URL;
},
isDevelopment(): boolean {
return configs.ENVIRONMENT === Environments.DEVELOPMENT;