Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fetch("api.something.com/films")
- .then(response => {
- // response object
- // calling JSON returns response body in JSON format, kinda like JSON.parse(body) but it handles reading the body until completion for you
- return response.json();
- }).then(films => {
- // the paramter "films" can be called whatever you want, you're simply passing a function that takes in one param
- // do whataver you want with the films
- // its an array of objects
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement