【问题标题】:Failing fetch request with ofx body使用 ofx 正文获取请求失败
【发布时间】:2018-04-28 00:28:41
【问题描述】:

可能我错过了什么 尝试在带有 XML OFX 正文的反应应用程序中运行获取请求, POSTMAN 请求成功通过,但 fetch 返回 404。 示例:

    const body = '<?xml version="1.0" encoding="UTF-8"?><OFX><SIGNONMSGSRQV1>...some body </SIGNUPMSGSRQV1></OFX>';
    const url = '10.10.10.110'// fake address
     fetch(url, {
      method: "POST",
      mode: 'cors',
      body: body,
      headers: {
          'Content-Type': 'application/x-ofx'
      }
    }).then((res)=>{
      console.log(res.status);
    }).catch((err) => {
      console.log('Err', err);
    })
 

正文:JSON.stringify(body) 给出相同的 404;

【问题讨论】:

    标签: javascript ajax reactjs fetch


    【解决方案1】:

    找出使用 fetch 发送该请求的方法 问题 ID 标头。 你不能在标题中发送 ofx

    const body = `<OFX>...request body...</OFX>`;
        const url = 'http://requestserver';
         return fetch(url, {
          method: "POST",
          body: body,
          mode: 'cors',
          headers: {
              'Content-Type': 'text/plain;charset=UTF-8"'
          }

    【讨论】:

      猜你喜欢
      • 2015-04-21
      • 2011-05-27
      • 1970-01-01
      • 2015-08-18
      • 1970-01-01
      • 2017-03-10
      • 2016-08-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多