diff --git a/open-in-web-browser.html b/open-in-web-browser.html index 867fb9a..0fde03f 100644 --- a/open-in-web-browser.html +++ b/open-in-web-browser.html @@ -3422,7 +3422,7 @@
then()
let stateOfLoading = 'Not Loading'; // this is the default state
-fetch('https://swapi.co/api/peoples/') // breaks because the URL is people not peoples
+fetch('https://swapi.dev/api/peoples/') // breaks because the URL is people not peoples
.then((response) => {
if(!response.ok){ // run if fetch fails
throw Error('api call broke'); // catch() is called
@@ -4129,25 +4129,25 @@ 8.5 : The await
operator is sequential
(async () => { // create async function that is immediately invoked
// sequential fetch's
- const responsePlants = await fetch('https://swapi.co/api/planets');
+ const responsePlants = await fetch('https://swapi.dev/api/planets/');
// API call above has to finish before the API below can start
- const responseFilms = await fetch('https://swapi.co/api/films');
+ const responseFilms = await fetch('https://swapi.dev/api/films/');
console.log(responsePlants.ok, responseFilms.ok) // logs true true
// parallel fetch's, faster than sequential fetch's using Promise.all()
const [parallelResponsePlanets, parallelResponseFilms] = await Promise.all([
- fetch('https://swapi.co/api/planets'),
- fetch('https://swapi.co/api/films')
+ fetch('https://swapi.dev/api/planets/'),
+ fetch('https://swapi.dev/api/films/')
]);
console.log(parallelResponsePlanets.ok, parallelResponseFilms.ok) // logs true true
// parallel fetch's, return first one to finish, using Promise.race()
const fastestResponseFromStarWarsApi = await Promise.race([
- fetch('https://swapi.co/api/species'),
- fetch('https://swapi.co/api/vehicles'),
- fetch('https://swapi.co/api/starships')
+ fetch('https://swapi.dev/api/species/'),
+ fetch('https://swapi.dev/api/vehicles/'),
+ fetch('https://swapi.dev/api/starships/')
]);
console.log(fastestResponseFromStarWarsApi.ok); // logs true