美文网首页
post 数据发送、接受(node 服务)

post 数据发送、接受(node 服务)

作者: ahappyone | 来源:发表于2018-09-17 20:00 被阅读0次

    背景:前端用 fetch 发请求,在 node 服务端获取 post 请求数据

    方案:前后端均需配置

    1、前端 fetch 配置:body 参数需转换为 ‘a=1&b2’ 的形式,可使用 querystring;(2)content-type 需设置为 application/x-www-form-urlencoded

    2、node 配置:使用 koa-bodyparser 即可

    然后即可从ctx.request.body中取出 body 对象

    相关文章

      网友评论

          本文标题:post 数据发送、接受(node 服务)

          本文链接:https://www.haomeiwen.com/subject/ntgxxftx.html