Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
284 views
in Technique[技术] by (71.8m points)

fetch调接口只有options请求的问题

今天使用fetch调接口,发现只有一个options预请求,没有后续的post请求,代码如下

fetch('http://sci.hoptest.haier.net:9900/haierbpm/operation/bpm/ws/history',
  {
     body:{ instanceId },
     headers: {
       'locale': 'en_US',
       'content-type': 'application/json',
     },
     method: 'POST'
  }
).then(res => {
  console.log(res)
})

现象如下 image.png

image.png

第一次用fetch实际调接口,请教这是啥问题


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

为了获取服务端设置的跨域配置,然后根据返回的 header 中的信息,来看这个接口允许哪些方法请求,允许携带哪些 header,是否允许当前域名跨域请求等等...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...