Rather than try/catch & async/await:
|
try { |
|
let response = await fetch(url); |
|
let json = await response.json(); |
|
return json; |
|
} catch (error) { |
|
console.log(error); |
|
} |
You could add a .then to your fetch to process the json
fetch(url)
.then(response => response.json())
.then(data => setUserData({ name: data.name, avatar_url: data.avatar_url })).then(() => setCurrentPage('hula'));
Rather than try/catch & async/await:
recatweek/src/utils/getProfile.js
Lines 4 to 10 in c302667
You could add a .then to your fetch to process the json