• <legend id='VfFQU'><style id='VfFQU'><dir id='VfFQU'><q id='VfFQU'></q></dir></style></legend>

    <small id='VfFQU'></small><noframes id='VfFQU'>

    1. <i id='VfFQU'><tr id='VfFQU'><dt id='VfFQU'><q id='VfFQU'><span id='VfFQU'><b id='VfFQU'><form id='VfFQU'><ins id='VfFQU'></ins><ul id='VfFQU'></ul><sub id='VfFQU'></sub></form><legend id='VfFQU'></legend><bdo id='VfFQU'><pre id='VfFQU'><center id='VfFQU'></center></pre></bdo></b><th id='VfFQU'></th></span></q></dt></tr></i><div id='VfFQU'><tfoot id='VfFQU'></tfoot><dl id='VfFQU'><fieldset id='VfFQU'></fieldset></dl></div>
        <bdo id='VfFQU'></bdo><ul id='VfFQU'></ul>

        <tfoot id='VfFQU'></tfoot>
      1. 使用来自服务器的表单数据在客户端上获取响应

        fetch response on client with form-data from server(使用来自服务器的表单数据在客户端上获取响应)
      2. <tfoot id='L98Uh'></tfoot>

          <i id='L98Uh'><tr id='L98Uh'><dt id='L98Uh'><q id='L98Uh'><span id='L98Uh'><b id='L98Uh'><form id='L98Uh'><ins id='L98Uh'></ins><ul id='L98Uh'></ul><sub id='L98Uh'></sub></form><legend id='L98Uh'></legend><bdo id='L98Uh'><pre id='L98Uh'><center id='L98Uh'></center></pre></bdo></b><th id='L98Uh'></th></span></q></dt></tr></i><div id='L98Uh'><tfoot id='L98Uh'></tfoot><dl id='L98Uh'><fieldset id='L98Uh'></fieldset></dl></div>
        • <legend id='L98Uh'><style id='L98Uh'><dir id='L98Uh'><q id='L98Uh'></q></dir></style></legend>

            <tbody id='L98Uh'></tbody>

            • <small id='L98Uh'></small><noframes id='L98Uh'>

                <bdo id='L98Uh'></bdo><ul id='L98Uh'></ul>

                  本文介绍了使用来自服务器的表单数据在客户端上获取响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 Express 服务器上使用 Node 'form-data' 模块来构造对来自客户端浏览器的 fetch 请求的 multipart/form-data 响应(这也是使用 fetch 的 multipart,但在服务器上接收良好在服务器上使用 multer).当服务器发回表单数据响应时,我在获取客户端收到响应时收到错误 - 无法将内容解析为 FormData."(本机 FormData)(注意:这与 Express 解析器不解析多部分不同,这是浏览器上的本机获取客户端,不解析节点表单数据)我在服务器响应或客户端响应处理中做错了什么?

                  I am using the Node 'form-data' module on an Express server to construct a multipart/form-data response to a fetch request from the client browser (which also a multipart using fetch, but is received fine at the server using multer on the server). When server sends back a form-data response I get error at the fetch client on receipt of response - "Could not parse content as FormData."(the native FormData) (Note: This is different from Express parsers not parsing multipart, this is the native fetch client on browser not parsing a node form-data) What am I doing wrong in the server response or client repsonse processing?

                  在服务器上:

                  const formdata = require('form-data')
                  app.post(req,res,next) {
                  // ... process the request and construct form-data response...//
                  
                  var form = new formdata(); 
                  form.append("serverResponse", "Reply from server to fetch request from client")
                  res.end(form.getBuffer())
                  }
                  

                  在客户端

                  //... send request to server which has no problem, but returncannot decode the response as FormData
                  
                   return fetch(  pRequest   )
                      .then(response => { 
                        return response.formData()   //***this throws 'Could not parse content as FormData***
                      }
                      .then(result => console.log(JSON.stringify(result))
                  

                  推荐答案

                  设置标题Content-Type"您对multipart/form-data"的回复.

                  Set the header "Content-Type" of your response to "multipart/form-data".

                  这篇关于使用来自服务器的表单数据在客户端上获取响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  业务场景:使用update语句去更新数据库字段。 原因:update接收值不正确。原来代码: $query = "UPDATE student SET date = now() WHERE id = $id";$result = $mysqli-query($query2) or die($mysqli-error); // 问题出现了在这句 $data = $result-fetch_ass
                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  <tfoot id='9PoVu'></tfoot>
                  • <bdo id='9PoVu'></bdo><ul id='9PoVu'></ul>

                      <legend id='9PoVu'><style id='9PoVu'><dir id='9PoVu'><q id='9PoVu'></q></dir></style></legend>
                        <tbody id='9PoVu'></tbody>

                      <small id='9PoVu'></small><noframes id='9PoVu'>

                        <i id='9PoVu'><tr id='9PoVu'><dt id='9PoVu'><q id='9PoVu'><span id='9PoVu'><b id='9PoVu'><form id='9PoVu'><ins id='9PoVu'></ins><ul id='9PoVu'></ul><sub id='9PoVu'></sub></form><legend id='9PoVu'></legend><bdo id='9PoVu'><pre id='9PoVu'><center id='9PoVu'></center></pre></bdo></b><th id='9PoVu'></th></span></q></dt></tr></i><div id='9PoVu'><tfoot id='9PoVu'></tfoot><dl id='9PoVu'><fieldset id='9PoVu'></fieldset></dl></div>