mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-09 18:45:38 +00:00
af84a589c5
* add redux-promise-middleware to package.json and update package-lock.json * intergrate redux-promise-middleware and simplify rates by replacing saga with promise * fix unrelated breaking test * -improve user messaging when network request fails. \n Clean up rates actions and reducers * Address tslint errors
22 lines
455 B
TypeScript
22 lines
455 B
TypeScript
export function checkHttpStatus(response) {
|
|
if (response.status >= 200 && response.status < 300) {
|
|
return response;
|
|
} else {
|
|
return new Error(response.statusText);
|
|
}
|
|
}
|
|
|
|
export function parseJSON(response) {
|
|
return response.json();
|
|
}
|
|
|
|
export async function handleJSONResponse(response, errorMessage) {
|
|
if (response.ok) {
|
|
return await response.json();
|
|
}
|
|
if (errorMessage) {
|
|
throw new Error(errorMessage);
|
|
}
|
|
return false;
|
|
}
|