Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface CheckResponseProps {
- res: any;
- //successCodes?: Array<number>;
- //errorCodes?: {[key: number]: (error: Error) => void};
- delegate?: any;
- }
- const checkResponse = ({
- res,
- //successCodes = [200, 201],
- //errorCodes,
- delegate,
- }: CheckResponseProps) => {
- console.log('comes in check response loop');
- console.log('*******RES ia ', res);
- let successCodes = [200, 201];
- if (successCodes.includes(res.status)) {
- console.log('here is success block');
- return res;
- } else {
- // if (errorCodes && errorCodes[res.status]) {
- // console.log('here is errorcode block');
- // handleError(
- // errorCodes[res.status](new APIError(res.status, res.message)),
- // );
- // } else {
- delegate = res;
- console.log('here is else block');
- handleError({error: new APIError(res.status, res.message), delegate});
- //}
- }
- };
- export default checkResponse;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement