axios

记录一次springboot+vue+axios进行大文件上传失败的问题(前端+后端)

 ̄綄美尐妖づ 提交于 2020-12-04 14:20:11
第一步:修改springboot multipart 的配置 spring: servlet: multipart: max -file - size: 5000MB max -request-size: 5000MB 第二步:修改tomcat服务器连接时间(还是springboot的配置文件) server: connection -timeout: 18000000 前端依旧报错:报错如下 第三步:增大前端VUE 发送异步请求axios的超时时间 customRequest(data){ // 上传提交 this. $message .success( " 文件正在上传! " ); const formData = new FormData() ; formData.append('file', data.file); console.log( " data " + data); formData.append('token', " token " ) this.axios({ method: 'post', timeout: 900000, // 这个就是重点 url: ' /hdfs/ saveFile', headers: { }, params:{ }, data: formData }).then((response) => { console.log

使用axios发送请求,遇到会发两次的情况

自古美人都是妖i 提交于 2020-12-03 11:55:27
在学习php&mySQL的过程中,前端nuxt用(vue官方推荐的)axios发送post请求,以实现向数据库插入页面提交数据的功能。 发现功能是实现了,但数据库中表的数据是这样的 很莫名其妙的多出空行,由于是初学者,费了好长时间找是不是自己php连接数据库的代码出了什么问题,但并没有发现疏漏。 于是找回前端,确定axios请求只触发了一次后,看了下浏览器控制台network,发现每次点击提交都会出现2次请求,对比一下发现第一次请求是这样的 下边的login.php才是正常的post请求。那么本着不懂就要问的不要脸精神,去网上找答案: https://blog.csdn.net/Homer_Simpson/article/details/89188068 写得很明白,复杂请求,就会自动进行一次预请求,和我们没关系。那么尝试解决这个问题:php中做一下判断 1 if (! $_SERVER ['REQUEST_METHOD']=== 'POST' ) { 2 die ('不是post请求忽略' ); 3 } 自己是个菜鸟,看php连接数据库的写法是这样的: 就给die()方法也拿过来试一哈,结果不出意料的失败了。于是接着找: https://blog.csdn.net/qq_30378229/article/details/78576625 写得原因是一样的,但这个给出了解决的代码:

VUE前端框架

自闭症网瘾萝莉.ら 提交于 2020-12-03 11:52:01
Vue项目环境搭建 1) 安装node   官网下载安装包,傻瓜式安装:https://nodejs.org/zh-cn/ 2) 换源安装cnpm   >: npm install -g cnpm --registry=https://registry.npm.taobao.org 3) 安装vue项目脚手架   >: cnpm install -g @vue/cli 注:2或3终端安装失败时,可以清空 npm缓存 再重复执行失败的步骤   npm cache clean --force Vue项目创建   1) 进入存放项目的目录  d: 切换D盘  cd D:\python_workspace\day66\代码   2) 创建项目  vue create v-proj   3) 项目初始化 选择 Manually select features     默认选择的有Babel Linter / Formatter 在添加Router 和 Vuex     选择YES     选择第一个,直接进入     直接第一个进入     选择第一个In dedicated config files,第一个自己处理     选择NOT    加载环境     选择改变端口号的地方,然后点击左边加号,选择npm,然后在右边Name中填写v-proj,

How do I post to Django using Axios?

↘锁芯ラ 提交于 2020-12-02 11:11:02
问题 I'm moving from Jquery AJAX to Axios since I'm using ReactJS so I think it's cleaner, I am having some troubles posting a simple request to the server, the post method goes through my view but whenever I print(request.POST) I have an empty queryset ( <QueryDict: {}> ). Here's the JS: axios({ method: 'post', url: SITE_DOMAIN_NAME + '/my_url_name/', #http://127.0.0.1:8000/my_url_name data: { 'tes1':'test', 'tes2':'test' }, headers: { "X-CSRFToken": CSRF_TOKEN, "content-type": "application/json"

How do I post to Django using Axios?

自闭症网瘾萝莉.ら 提交于 2020-12-02 11:00:46
问题 I'm moving from Jquery AJAX to Axios since I'm using ReactJS so I think it's cleaner, I am having some troubles posting a simple request to the server, the post method goes through my view but whenever I print(request.POST) I have an empty queryset ( <QueryDict: {}> ). Here's the JS: axios({ method: 'post', url: SITE_DOMAIN_NAME + '/my_url_name/', #http://127.0.0.1:8000/my_url_name data: { 'tes1':'test', 'tes2':'test' }, headers: { "X-CSRFToken": CSRF_TOKEN, "content-type": "application/json"

昨天我收到了美团和阿里的面试,but…...

三世轮回 提交于 2020-11-30 23:37:52
临近毕业,浑浑噩噩了三四年,即将踏出校门,此时的内心说不恐惧和迷茫是假的,但是作为祖国未来栋梁之才的我,还是非常淡定的拿出了“你不知道的JavaScript”,认认真真的学了起来,虽然此时的思绪完全不在学习上… 经理: 小周,你去帮李晴调一下bug,咱们的产品今天要上线,尽快做完,大家早点回家。 我: 好的,没问题,交给我吧! 晴: 周哥麻烦你了,这个功能实在是太复杂了。 我: 没事,小case,看我的! 然后我十指在键盘上飞快的奔跑,一行行的代码就像一件完美的艺术品,一点点展示在我的眼前…不到半个小时,搞定! 晴: 周哥你太厉害了,我一天多都没搞出来,你这么一会就解决了,你帮了我一个大忙,今晚请你吃饭! 哇咔咔,美女,晚上,请吃饭,是不是会发生点什么…(#^.^#) 叮铃铃…,此时电话突然响了起来,打段了我一辈子的好事(•́へ•́╬) 我: 喂?您好! HR: 您好,请问是周先生吗? 我: 是的,您是哪位? HR: 我是美团的HR,看到您有投递给我们前端开发岗的简历,想约您参加我们的电话面试,不知道您现在是否方便? 我: (此时内心非常的激动,美团啊!!)有时间,有时间,我需要准备什么吗? HR: 这样的,我先向您了解一下基本情况,稍后通知我们的技术主管负责给您进行技术上的面试。 这样聊了三分钟左右的,在学校表现、是否毕业、发展规划、所学专业等,和HR结束通话后大约五分钟

Updating Data in Firebase using React and Axios

为君一笑 提交于 2020-11-29 12:17:19
问题 I'm trying to update some data in a firebase database. However i am unable to get the updateAPI function to work properly. I believe it's something to do with axios.put, the url is probably not traversing the data correctly? I have tried changing the url but end up with a OPTIONS and CORS errors which means the url is incorrect. // API Function calls async getAPI(){ const response = await axios.get('https://fir-test-euifhefibewif.firebaseio.com/todos.json') console.log(response) console.log

Updating Data in Firebase using React and Axios

你说的曾经没有我的故事 提交于 2020-11-29 12:16:11
问题 I'm trying to update some data in a firebase database. However i am unable to get the updateAPI function to work properly. I believe it's something to do with axios.put, the url is probably not traversing the data correctly? I have tried changing the url but end up with a OPTIONS and CORS errors which means the url is incorrect. // API Function calls async getAPI(){ const response = await axios.get('https://fir-test-euifhefibewif.firebaseio.com/todos.json') console.log(response) console.log

Vue--前端交互 axios

笑着哭i 提交于 2020-11-28 13:01:24
1. axios 的基本特性 axios是基于Promise用于浏览器和node.js的HTTP客户端 特征: 支持浏览器和node.js 支持 promise 能拦截请求和响应 自动转换JSON数据 2. axios 的基本用法 axios . get ( '/adata' ) . then ( ret => { console . log ( ret . data ) //data属性固定,用于获取后台响应数据 } ) 3. axios的参数传递 1.get 通过 restful 传递参数 也可以通过 params 选项传递参数 //restful axios . get ( 'http://localhost:3000/axios/123' ) . then ( function ( ret ) { console . log ( ret . data ) ; } ) //params axios . get ( 'http://localhost:3000/axios' , { params : { id : 789 } } ) . then ( function ( ret ) { console . log ( ret . data ) ; } ) 2.delete 与get传参类似 axios . delete ( 'http://localhost:3000