2
ReactJS - Redux 프론트 응용 프로그램에서 REST API 응답의 위치 헤더 값을 가져 오려고합니다. 나는이 컬 때ReactJS의 가져 오기 요청에서 헤더 위치 값을 얻는 방법
:
curl -i -X POST -H "Authorization: Bearer MYTOKEN" https://url.company.com/api/v1.0/tasks/
나는이 대답 유무 : 내가 만들 때
HTTP/1.1 202 ACCEPTED
Server: nginx
Date: Fri, 12 Aug 2016 15:55:47 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 0
Connection: keep-alive
Location: https://url.company.com/api/v1.0/tasks/status/idstatus
을 내가 어떤 헤더가없는 ReactJS
var url = 'https://url.company.com/api/v1.0/tasks/'
fetch(url, {
method: 'post',
credentials: 'omit',
headers: {
'Authorization': `Bearer ${token}`
}
}
)
에서 가져 오기 응답 객체 : No header in Fetch request
헤더가 비어로, 나는 빈 결과를,response.headers.get('Location');
그러나 잘 : 1,363,210
나는 https://developer.mozilla.org/en-US/docs/Web/API/Headers에서 발견 한 모든 response.headers 기능을 시도했다.
왜 헤더 값으로 채워진 적절한 헤더 객체를 얻을 수 없는지 아십니까? 사전에
감사합니다, 요한
fetch api에서 특정 헤더 만 노출 될 수 있습니다. http://stackoverflow.com/a/5837798/1515758 – John
Thx @ John, 나에게 많은 도움이되었습니다. –