javascript - NodeJS:@esri/arcgis-rest-request - 如何调整 Fetch 选项?
问题描述
我希望在使用@esri/arcgis-rest-request 发出请求时调整Fetch 请求选项,但不幸的是我找不到与此相关的任何文档。
import fetch from "node-fetch";
import FormData from "isomorphic-form-data";
import arcgisRestRequest from "@esri/arcgis-rest-request";
arcgisRestRequest.setDefaultRequestOptions({ fetch, FormData });
arcgisRestRequest.request("https://www.arcgis.com/sharing/rest/info")
.then(response => console.log(response));
使用请求方法时,我收到有关 NodeJS 服务器证书的错误:
FetchError: request to https://xxx/server/rest/self?token=xxx=json failed, reason: unable to get local issuer certificate
我想通过类似的东西:
const fetchOptions = {
...
agent:new https.Agent({rejectUnauthorized: false}),
...
};
以避免证书错误。
我怎样才能做到这一点?
解决方案
Looking at their code it looks like you should be able to just do
arcgisRestRequest.request(
"https://www.arcgis.com/sharing/rest/info",
{
agent:new https.Agent({rejectUnauthorized: false})
}
)
.then(response => console.log(response));
推荐阅读
- apache - Apache htaccess 缓存
- amazon-s3 - 日期为“通配符参数”的 aws cp 文件
- azure - Azure AD B2C 'newUser' 和 'auth_time' 声明生命周期
- php - 无法在 wamp64 中使用 mail() 或 phpmailer 通过 php 发送邮件
- javascript - 在流星 js 中显示来自 mongodb 的 Summernote 内容时出错
- java - AbstractHttpMessageConverter 中的 readInternal 和 read 有什么区别?
- c# - ASP.NET MVC 在 Windows 身份验证中覆盖用户
- node.js - Node.js:为什么 Braintree 方法通过错误响应来解决 promise?
- bash - 在 bash 中遍历所有扩展名为 .txt 的文件
- azure - 为 Azure VM 中托管的 Web 应用程序禁用匿名身份验证