zoukankan      html  css  js  c++  java
  • request.json和request.form

    一、fetch请求时,request.json能获取到数据,request.form获取不到数据

     1 var data = {'name':'test'};
     2  
     3 fetch('http://localhost:8000/v1/user/get', {
     4   method: 'POST', // or 'PUT'
     5   body: JSON.stringify(data), // data can be `string` or {object}!
     6   headers: new Headers({
     7     'Content-Type': 'application/json'
     8   })
     9 }).then(res => res.json())
    10 .catch(error => console.error('Error:', error))
    11 .then(response => console.log('Success:', response));

    二、使用ajax的时候,request.json获取不到数据,request.form能获取到数据

    1 $.ajax({
    2         url:"http://localhost:8000/v1/user/get",
    3         type:'post',
    4         dataType:'json',
    5         data:{'type':'ffxc','page':'1','per_page':'10'},
    6         success:function(result){
    7             console.log(result);
    8         }
    9     });

    三、使用python的requests的post,request.json获取不到数据,request.form能获取到数据

    1 import requests
    2 data = {'name':'test'}
    3 url = '
    4 r = requests.post(url, data=data)

    原文链接:https://coding.imooc.com/learn/questiondetail/70536.html

  • 相关阅读:
    生产者与消费者
    .net 重新注册
    linux 网络之 bond 网卡模式
    Rancher
    kubernetes 集群
    centos7 网卡命名
    Redis 主从模式
    Redis 集群
    Redis
    TwemProxy Redis架构
  • 原文地址:https://www.cnblogs.com/rainbow-1/p/14644004.html
Copyright © 2011-2022 走看看