᠌
Size: a a a
᠌
В
DE
᠌
DE
᠌
᠌
DE
DE
᠌
В
const swapi = (url) => (...path) =>
fetch(`https://swapi.dev/api/${[url, ...path].join('/')}/`)
.then((response) => response.ok
? response.json()
: Promise.reject(`Could not fetch data from ${url}, received ${response.status}`))
const people = swapi('people');
people()
.then((data) => {
console.log('all people received', data)
}).catch(console.error)
const id = 25
people(id)
.then((data) => {
console.log(`person by id ${id} received`, data)
}).catch(console.error)
S
const swapi = (url) => (...path) =>
fetch(`https://swapi.dev/api/${[url, ...path].join('/')}/`)
.then((response) => response.ok
? response.json()
: Promise.reject(`Could not fetch data from ${url}, received ${response.status}`))
const people = swapi('people');
people()
.then((data) => {
console.log('all people received', data)
}).catch(console.error)
const id = 25
people(id)
.then((data) => {
console.log(`person by id ${id} received`, data)
}).catch(console.error)
p
p
iH
p
const swapi = (url) => (...path) =>
fetch(`https://swapi.dev/api/${[url, ...path].join('/')}/`)
.then((response) => response.ok
? response.json()
: Promise.reject(`Could not fetch data from ${url}, received ${response.status}`))
const people = swapi('people');
people()
.then((data) => {
console.log('all people received', data)
}).catch(console.error)
const id = 25
people(id)
.then((data) => {
console.log(`person by id ${id} received`, data)
}).catch(console.error)
iH
iH
В
p