Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getProducts() {
const headers = new Headers({
'Content-Type': 'application/json'
});
return (dispatch) => {
return fetch('http://localhost:3000/api/products', {
method: 'GET',
headers
}).then((response) => {
return response.json().then((data) => {
return dispatch({
type: GET_PRODUCTS,
notifications: data
});
});
}).catch(() => {
return dispatch({ type: `${GET_PRODUCTS}_ERROR` });
_getHeaders() {
let headers = new Headers(this.headers || {});
if (headers.has('Content-Length')) {
headers.set('Content-Length', this.body.length);
}
return headers;
}