For rest api request javascript, async/await is your friend.
```javascript
async function getData() {
try {
const res = await fetch('url');
if (!res.ok) throw new Error('Failed');
const data = await res.json();
return data;
} catch (err) {
console.error('Boom:', err);
}
}
```
Always wrap in try/catch. And yeah, Axios is way more intuitive.
```javascript
async function getData() {
try {
const res = await fetch('url');
if (!res.ok) throw new Error('Failed');
const data = await res.json();
return data;
} catch (err) {
console.error('Boom:', err);
}
}
```
Always wrap in try/catch. And yeah, Axios is way more intuitive.
