_mercury – 19-25 Aug 15

what could be wrong here ?
M
_mercury610d ago
this route is working if i did it by a browser
const getAttributes = async () => {
const res = await fetch('/api/attributes');
console.log('res', res);

const attrs = await res.json();
console.log('d', attrs);
setAttributes(attrs);
};

useEffect(() => {
getAttributes();
}, []);
const getAttributes = async () => {
const res = await fetch('/api/attributes');
console.log('res', res);

const attrs = await res.json();
console.log('d', attrs);
setAttributes(attrs);
};

useEffect(() => {
getAttributes();
}, []);
UU
Unknown User610d ago
M
_mercury610d ago
console.log('res', res); not appear and method not called
UU
Unknown User610d ago
M
_mercury610d ago
I called it in useEffect ?
UU
Unknown User610d ago
M
_mercury610d ago
I have another Error in the code may be it stops react
UU
Unknown User610d ago
M
_mercury610d ago
yes i removed the comp that creates the erropr And i see it works thx
UU
Unknown User610d ago