2020-07-27 22:04:12 +02:00
|
|
|
// @flow
|
|
|
|
export default function handleFetchResponse(response: Response): Promise<any> {
|
2021-08-17 16:03:25 +02:00
|
|
|
const headers = response.headers;
|
|
|
|
const poweredBy = headers.get('x-powered-by');
|
2022-06-22 15:43:54 +02:00
|
|
|
const uuid = headers.get('x-uuid');
|
2021-08-17 16:03:25 +02:00
|
|
|
|
|
|
|
return response.status === 200
|
2022-06-22 15:43:54 +02:00
|
|
|
? response.json().then((body) => ({ body, poweredBy, uuid }))
|
2021-08-17 16:03:25 +02:00
|
|
|
: Promise.reject(new Error(response.statusText));
|
2018-03-26 23:32:43 +02:00
|
|
|
}
|