本文介绍了Nodejs Parse 获取包含对象 [Symbol(map)] 的响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
不知道如何访问参数x-error-detail-header.
I do not know how to access the parameter x-error-detail-header.
我从使用 node-fetch npm 包的请求中收到此响应标头:
I receive this response headers from a request using node-fetch npm package:
Headers {
[Symbol(map)]:
{ 'content-type': [ 'text/xml' ],
date: [ 'Fri, 27 Apr 2018 09:46:56 GMT' ],
'retry-after': [ '51184' ],
server: [ 'xxxxx' ],
'x-error-detail-header': [ 'Account Over Rate Limit' ],
'x-x-error-code': [ 'ERR_403_DEVELOPER_OVER_RATE' ],
'x-x-responder': [ 'xxxxxxx.com' ],
'x-plan-qps-allotted': [ '2' ],
'x-plan-qps-current': [ '1' ],
'x-plan-quota-allotted': [ '50' ],
'x-plan-quota-current': [ '51' ],
'x-plan-quota-reset': [ 'Saturday, April 28, 2018 12:00:00 AM GMT' ],
'content-length': [ '28' ],
connection: [ 'Close' ] } }
我的问题是我不知道如何访问 [Symbol(map)] 对象中的参数.
My problem is that I do not know how to access the parameters that are inside [Symbol(map)] object.
推荐答案
它是一个 Headers 对象一个>.它有例如get
和 forEach
方法.例如:
It is a Headers object. It has e.g. get
and forEach
methods. For example:
getDownload = async (url) => {
const response = await fetch(url);
console.log(response.headers.get('content-type'));
return {
name: response.headers.get('Content-Disposition'),
length: response.headers.get('content-length')
}
}
注意不区分大小写.
这篇关于Nodejs Parse 获取包含对象 [Symbol(map)] 的响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!