12345678910111213141516171819202122232425262728293031323334 |
- //SWAPI Links
- {
- async function jsonTable (obj){
- for(let el in obj){
-
-
- if(Array.isArray(obj[el])){
- let i = 0
- for(let elArr of obj[el]){
- async function btn (link){
- let res = await fetch(link)
- let data = await res.json()
- return obj[el][i]=data
- }
- if(elArr.indexOf("https://swapi.dev")!== -1){
- await btn(elArr)
- }
- i++
- }
- }
- if(obj[el].indexOf("https://swapi.dev")!== -1){
- fetch(obj[el])
- .then(res => res.json())
- .then(luke => obj[el]=luke)
- }
- }
- console.log(obj)
- }
- fetch('https://swapi.dev/api/people/20')
- .then(res => res.json())
- .then(luke =>jsonTable(luke))
- }
|