【记录一次坑经历】axios使用x-www-form-urlencoded 服务器报400(错误的请求。 )(后端.Net MVC5 WebApi OAuth,前端Electron-Vue)
- 首先放上源码
electron-vue axios 注册
axios.defaults.baseURL = 'http://localhost:8888/' axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8';
axios.defaults.withCredentials = true Vue.prototype.axios = axios

- axios 请求
this.axios({
method: 'post',
url: '/token',
data: {
grant_type: 'password',
UserName: '11219000'
},
}).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.log(error);
});

- 请求错误 情况截图:

400(错误的请求。 )
- 正常postman截图:



axios的Request Body 错了
下面用ajax测试下:


- 在请求头x-www-form-urlencoded下,ajax传的 From Data是字符串,而axios传的是json
我不知道了为什么,但传字符串好像能行,传对象会变成JSON,传字符串就和AJAX一样了


哇 成功了.
嗯 到底是为什么....
到底是为什么....
为什么....
么....
....
【记录一次坑经历】axios使用x-www-form-urlencoded 服务器报400(错误的请求。 )(后端.Net MVC5 WebApi OAuth,前端Electron-Vue)的更多相关文章
- 记录 SpringBoot 踩坑经历
1.spring-boot-starter-web 作用 <dependency> <groupId>org.springframework.boot</groupId& ...
- 自己挖的坑自己填-- maven打jar包部署服务器报错
1.今天 mvn install 后把 jar 包部署到服务器上,执行 java -jar xx.jar 报 "no main manifest attribute,in xx.jar&qu ...
- 从Ueditor跨域上传,总结的一次跨域上传的爬坑经历
项目内其中一个管理后台需要发布文章,需要一个富文本编辑器,经过一番选择后,最终选择了百度的Ueditor. 由于上传的文件是上传到另一台专门存放图片等静态资源的服务器上面的,所以就涉及到了跨域上传. ...
- 『审慎』.Net4.6 Task 异步函数 比 同步函数 慢5倍 踩坑经历
异步Task简单介绍 本标题有点 哗众取宠,各位都别介意(不排除个人技术能力问题) —— 接下来:我将会用一个小Demo 把 本文思想阐述清楚. .Net 4.0 就有了 Task 函数 —— 异步编 ...
- TiDB 深度实践之旅--真实“踩坑”经历
美团点评 TiDB 深度实践之旅(9000 字长文 / 真实“踩坑”经历) 4 PingCAP · 154 天前 · 3956 次点击 这是一个创建于 154 天前的主题,其中的信息可能已经有所发 ...
- Net4.6 Task 异步函数 比 同步函数 慢5倍 踩坑经历
Net4.6 Task 异步函数 比 同步函数 慢5倍 踩坑经历 https://www.cnblogs.com/shuxiaolong/p/DotNet_Task_BUG.html 异步Task简单 ...
- myeclipse使用db-brower连接到sqlserver2012踩坑经历
myeclipse使用db-brower连接到sqlserver踩坑经历 首先得建立个角色 右键->创建登录名 权限开大点 连接设置 Driver template选择我选这个,格式按照我的写 ...
- sqlserver安装和踩坑经历
sqlserver安装和踩坑经历 下载 下载 安装 大致是按照这个来的 安装教程 出错 windows系统安装软件弹出"Windows installer service could not ...
- Dubbo 服务 IP 注册错误踩坑经历
个人博客地址 studyidea.cn,点击查看更多原创文章 踩坑 公司最近新建一个机房,需要将现有系统同步部署到新机房,部署完成之后,两地机房同时对提供服务.系统架构如下图: 这个系统当前对外采用 ...
随机推荐
- ECS云服务器配置数据库远程链接
环境: windows server 2012 R2 Datacenter(数据中心版本) sql server 2008 R2 Express (环境的安装步骤此处不做教程) 开启远端链接重要步骤如 ...
- [LeetCode] Shifting Letters 漂移字母
We have a string S of lowercase letters, and an integer array shifts. Call the shift of a letter, th ...
- C++实验一
实验结论 2-28 if...else #include <iostream> #include <stdlib.h> using namespace std; int mai ...
- 在vue项目中mock数据
第一步:安装: 在命令行中执行: npm install mockjs; 第二步:定义index.js文件 我们新建一个mock文件夹,此文件夹中建一个index.js文件:在index.js中输入以 ...
- NeuChar 平台使用及开发教程(五):使用 NeuChar 的关键字回复服务
在上一篇<NeuChar 平台使用及开发教程(四):使用 NeuChar 的素材服务>中,我们已经完成了素材的添加,下面,让我们来设置一个关键字回复,并同步到应设置好Neural Endi ...
- CSS怎么在项目里引入自定义字体(@font-face)
前言: 以前我一直用内置的默认字体给文字设置字体,直到一天UI妹纸给了我下面的字体 当时我是蒙蔽的,这个字体的效果如下 默认字体并无该字体,直接设置是没有效果的,这时就需要用到自定义字体了 下面 ...
- [Swift]LeetCode508. 出现次数最多的子树元素和 | Most Frequent Subtree Sum
Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a ...
- [Swift]LeetCode552. 学生出勤记录 II | Student Attendance Record II
Given a positive integer n, return the number of all possible attendance records with length n, whic ...
- [Swift]LeetCode695. 岛屿的最大面积 | Max Area of Island
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) conn ...
- [Swift]LeetCode937. 重新排列日志文件 | Reorder Log Files
You have an array of logs. Each log is a space delimited string of words. For each log, the first w ...