Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const getEmails = async (pageNo = 1) => {
const response = await fetch(`${baseUrl}/api/inbox?page=${pageNo}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
});
if (response.status === 200) {
const body = await response.json();
// console.log('response: ', body);
const res = camelizeKeys(body)
console.log('RES: ', res);
return camelizeKeys(body);
}
throw new Error('Can not fetch emails');
};
try {
response = yield call(sagaFetch, endpointPath, options)
} catch (error) {
updateRunningFetches(error.response)
yield fork(handleRequestError, error, action)
return false
}
const { json, serverResponse } = response
updateRunningFetches(serverResponse)
payload.serverStatus = serverResponse.status
if (serverResponse.status === 200 || serverResponse.status === 201) {
payload.response = camelizeKeys(json)
const linkPagination = parseLink(serverResponse.headers.get('Link'))
// for now these need to remain parseInt instead of Number cast
// due to StreamContainer casting them as number and checking for 0
// when you do Number(null) it equals 0, thanks javascript!
linkPagination.totalCount = parseInt(serverResponse.headers.get('X-TotalCount'), 10)
linkPagination.totalPages = parseInt(serverResponse.headers.get('X-Total-Pages'), 10)
linkPagination.totalPagesRemaining = parseInt(serverResponse.headers.get('X-Total-Pages-Remaining'), 10)
payload.pagination = linkPagination
}
yield put({ meta, payload, type: SUCCESS })
yield call(fireSuccessAction)
return true
}
data => humps.camelizeKeys(JSON.parse(data)),
],
export default function normalisePostType (postType) {
const schema = Array.isArray(postType) ? arrayOf(postTypeSchema) : postTypeSchema;
return normalize(humps.camelizeKeys(postType), schema);
};
export default function normaliseRevision (revision) {
const schema = Array.isArray(revision) ? arrayOf(revisionSchema) : revisionSchema;
return normalize(humps.camelizeKeys(revision), schema);
};
export const camelize = (obj: Object | Object[]) =>
humps.camelizeKeys(obj, {
separator: '_',
});
return axios.get(path).then(res => {
return humps.camelizeKeys(res.data)
})
}
.then(response => {
const camelizedJson = camelizeKeys(response.body);
const normalized = normalize(camelizedJson, arrayOf(settingSchema));
return dispatch(doneLoadSettings(normalized));
})
.catch(error => {
.then(x => {
const data = camelizeKeys(x.data) as Sandbox;
this.loadedSandboxes[data.id] = data;
return data;
});
};
this.client.interceptors.response.use(response => {
const newResponse = response;
newResponse.data = humps.camelizeKeys(response.data);
return response;
});
}