NodeJS: @esri/arcgis-rest-request -如何调整Fetch选项?



我希望调整获取请求选项,当使用@esri/arcgis-rest-request发出请求时,但不幸的是,我找不到任何相关的文档。

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}),
...
};

避免证书错误。

我怎样才能做到这一点?

看看他们的代码,看起来你应该可以直接执行

arcgisRestRequest.request(
"https://www.arcgis.com/sharing/rest/info",
{
agent:new https.Agent({rejectUnauthorized: false})
}
)
.then(response => console.log(response));

相关内容

  • 没有找到相关文章

最新更新