What is the difference between fetching data with these two functions? I have seen people use them both and they seem to do the same thing, and if they're the same, which one is more correct/preferred?
function test() {
return fetch('https://jsonplaceholder.typicode.com/todos/1').then(res => {
return res.json();
});
}
and
async function test2() {
const res = await fetch('https://jsonplaceholder.typicode.com/todos/1');
return res.json();
}