Javascript 发出http请求
我想在我的React应用程序(带或不带Axios)上发出如下get请求。但我不知道如何添加我的身份验证令牌Javascript 发出http请求,javascript,reactjs,xmlhttprequest,Javascript,Reactjs,Xmlhttprequest,我想在我的React应用程序(带或不带Axios)上发出如下get请求。但我不知道如何添加我的身份验证令牌 curl -X GET https://server.url/acp-service/sites -H 'Content-Type: application/json' -H 'X-Authorization: eyJhbGciOiJIUzUxMiJ9.eyJ...long.string.here' 你能帮我吗?使用 当问题被标记时,为什么要“使用fetch()?”?! (async (
curl -X GET https://server.url/acp-service/sites -H 'Content-Type: application/json' -H 'X-Authorization: eyJhbGciOiJIUzUxMiJ9.eyJ...long.string.here'
你能帮我吗?使用
当问题被标记时,为什么要“使用fetch()?”?!
(async () => {
const rawResponse = await fetch(' https://server.url/acp-service/sites', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-Authorization': 'your_auth_string'
}
});
const content = await rawResponse.json();
console.log(content);
})();