在 NodeJS - ExpressJS 应用程序中找不到响应 Headers
Can't Find Response Headers in an NodeJS - ExpressJS App
我已经使用 node/express.js 设置了一个简单的 api 请求来访问 Feedly Dev Api:https://developer.feedly.com/。 Feedly Api 带有两个响应 headers -- 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 响应 headers?
谢谢。
获取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}`));
})();
我已经使用 node/express.js 设置了一个简单的 api 请求来访问 Feedly Dev Api:https://developer.feedly.com/。 Feedly Api 带有两个响应 headers -- 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 响应 headers?
谢谢。
获取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}`));
})();