I have the following module, in which there is a named function... eslint ( airbnb ) is raising an error:
8:1 error Prefer default export import/prefer-default-export
How should I restructure my code to comply to this requirement?
exports / imports should be at the beginning of the code...
module
import fetch from 'node-fetch';
const normalize = json => json.categories.map(category => ({
id: category.catId,
name: category.catName,
}));
export const getCategories = async () => {
const response = await fetch(
'http://mockbin.org/bin/0535d3fb-74f6-43a6-b4d4-461d84795be4',
{
method: 'GET',
headers: { accept: 'application/json' },
},
);
const json = await response.json();
return normalize(json);
};