request.json和request.form
发布时间:2021-05-20 14:17:03 所属栏目:大数据 来源: https://www.cnblogs.com/rainb
导读:一、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),1)"> data can be `string` or {ob
一、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),1)"> 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:'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'},1)">6 success:function(result){
7 console.log(result);
8 }
9 });
三、使用python的requests的post,request.json获取不到数据,request.form能获取到数据 import requests
2 data = {'name':test'}
3 url = '
4 r = requests.post(url,data=data)
原文链接:https://coding.imooc.com/learn/questiondetail/70536.html (编辑:北几岛) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |