下面是一个获取数据的示例fetch api
here
return fetch(
"URL",
{
headers: {
"Accept": "application/json",
"Authorization": "Basic " + btoa('username:password'),
"Content-Type": "application/json",
"User-Agent":
"Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25",
"x-correlation-id": "asfsef4243sdf",
"x-channel": "android"
},
method: "GET", // *GET, POST, PUT, DELETE, etc.
}
)
.then(response => {
console.log("got json" + response);
response.json();
})
.then(responseJson => {
console.log("Hey = "+responseJson);
})
.catch(error => {
console.error(error);
});