我已经使用node / express.js设置了一个简单的api请求来访问Feedly Dev Api:https://developer.feedly.com/。 Feedly Api带有两个响应标头-X-Ratelimit-Count
和X-Ratelimit-Reset
。问题是我不知道如何访问。
这是我的express.js文件的相关部分:
app.get('/feedly', async (request, response) => {
const apiUrl =
'https://cloud.feedly.com/v3/streams/contents?streamId=user/[USER_ID]/category/global.all'
const fetchResponse = await fetch(apiUrl, {
headers: {
Authorization: `Bearer ${process.env.FEEDLY_ACCESS_TOKEN}`
}
})
const json = await fetchResponse.json()
response.json(json)
response.end()
})
要查看X-Ratelimit-Count和X-Ratelimit-Reset响应标头,我该怎么做?
谢谢。
答案 0 :(得分:1)
获取API:Headers
(async() => {
const fetchResponse = await fetch("https://httpbin.org/anything");
console.log(fetchResponse.headers.get('X-Ratelimit-Count'))
console.log(fetchResponse.headers.get('X-Ratelimit-Reset'))
fetchResponse.headers.forEach((v, k) => console.log(`${k}: ${v}`));
})();