我尝试使用fetch()从https://swapi.co/获取数据。使用此代码,我不确定,但是在chrome的“网络”部分中,我看到了我需要的数据。我该如何访问?
fetch('https://swapi.co/api/people/1/')
.then(resp => resp.json)
.then(obj => console.log(obj));
您好,这将获取返回为json的数据
fetch('https://swapi.co/api/people/1')
.then(function(response) {
return response.json();
})
.then(function(myJson) {
console.log(JSON.stringify(myJson));
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句