async function fetchData() {
const [error, response] = await fetch('https://jsonplaceholder.typicode.com/todos/1')
if (error) {
console.log(error);
return
}
const [e, data] = await response.json()
if (e) {
console.log(e);
return
}
return data
}
fetchData()
I came across a LinkedIn post showing this it the new way to represents async/await without using try-catch block, is this right correct me if its wrong. its not working for me.