what does the fetch method return code example
Example 1: fetch api in js
var myData = async () => {
try {
const raw_response = await fetch("https://jsonplaceholder.typicode.com/users");
if (!raw_response.ok) {
throw new Error(raw_response.status);
}
const json_data = await raw_response.json();
console.log(json_data);
}
catch (error) {
console.log(error);
}
}
fetchUsers();
Example 2: fetch api
const url = "http://dummy.restapiexample.com/api/v1/employees";
fetchurl()
.then(res => {
console.log(res);
})
.catch(err => {
console.log('Error: ${err}' );
});