React JS Fetch
Fetch is a function to retrieve resources from a server
Example using .then
fetch('https://jsonplaceholder.typicode.com/todos')
.then((res) => res.json())
.then((data) => console.log(data.slice(0, 3)))
Example using async await
async function getText(file) {
let myObject = await fetch(file);
let myText = await myObject.json();
console.log(myText.slice(0, 3));
}
getText('https://jsonplaceholder.typicode.com/todos')