https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers
HTTP 消息头允许客户端和服务器通过 request和 response传递附加信息。 一个请求头由不区分大小写的名称后跟一个冒号“:”,然后跟然后值(不带换行符)组成。 该值前面的引导空白会被忽略。
http://www.tutorialspoint.com/http/http_header_fields.htm
https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
fetch('https://newsapi.org/v1/articles?source=the-next-web&sortBy=latest',{
method: 'get',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-Api-Key': `0987b00e542141369049e647701b65d9`
}
})
.then(function(response) {
return response.json()
}).then(function(json) {
console.log('parsed json: ', json)
}).catch(function(error) {
console.log('parsing failed: ', error)
});
fetch('https://newsapi.org/v1/articles?source=the-next-web&sortBy=latest&apiKey=0987b00e542141369049e647701b65d9')
.then(function(response) {
return response.json()
}).then(function(json) {
console.log('parsed json: ', json)
}).catch(function(error) {
console.log('parsing failed: ', error)
});
https://gist.github.com/xgqfrms-GitHub/d8afbd6484cf10da3603c6f51d6d4907
https://gist.github.com/xgqfrms-GitHub/636260e8332f0fe4f530fe040ffd3741