Fetch a resource from the network. It returns a Promise that resolves to the Response to that Request, whether it is successful or not.
Promise
Response
Request
Optional
const response = await fetch("http://my.json.host/data.json");console.log(response.status); // e.g. 200console.log(response.statusText); // e.g. "OK"const jsonData = await response.json(); Copy
const response = await fetch("http://my.json.host/data.json");console.log(response.status); // e.g. 200console.log(response.statusText); // e.g. "OK"const jsonData = await response.json();
2.0.0
Fetch a resource from the network. It returns a
Promisethat resolves to theResponseto thatRequest, whether it is successful or not.