axios

Reactjs Axios / Spring boot security

£可爱£侵袭症+ 提交于 2019-12-23 10:19:45
问题 I have a Java application developed with Spring Boot which is the back-end. The front-end is an application developed in ReactJs. I use REST services. I use axios for REST calls. I recently enabled the security in Spring Boot. Now I have difficulty to authenticate axios calls. var config = { auth: { username: 'bruker', password: 'passord' } }; axios.get('http://localhost:8090/employee/all', config).then(function (response) { console.log(response) }.bind(this)).catch(function (response) {

Reactjs Axios / Spring boot security

荒凉一梦 提交于 2019-12-23 10:17:13
问题 I have a Java application developed with Spring Boot which is the back-end. The front-end is an application developed in ReactJs. I use REST services. I use axios for REST calls. I recently enabled the security in Spring Boot. Now I have difficulty to authenticate axios calls. var config = { auth: { username: 'bruker', password: 'passord' } }; axios.get('http://localhost:8090/employee/all', config).then(function (response) { console.log(response) }.bind(this)).catch(function (response) {

I can't do a request that needs to set a header with axios

一个人想着一个人 提交于 2019-12-23 10:14:30
问题 I'm trying to get some datas from an external API (from Mashape) that requires a specific header to set the API key. Everything is ok using jQuery : $.ajax({ url: 'https://omgvamp-hearthstone-v1.p.mashape.com/cardbacks', type: 'GET', data: {}, dataType: 'json', success: function(data) { console.dir((data.source)); }, error: function(err) { alert(err); }, beforeSend: function(xhr) { xhr.setRequestHeader("X-Mashape-Authorization", "MY_API_KEY"); } }); However, when I'm trying to do the same

Multiple requests with axios without waiting for all of them to finish in an array list?

假如想象 提交于 2019-12-23 06:01:17
问题 taskList.push( const data = { url: 'http://${requestUrl}?${argsString}', headers: { 'Content-Type': 'application/octet-stream', Authorization: signature //, //'Content-Length': buffer.length }, method: 'POST', data: buffer } return axios(data) ) try { const data = await Promise.all(taskList) const res = data.map(d => d.data) console.log(res) //ctx.state.data = res } catch (e) { console.log(e) throw e } How to do not wait all requests finish, because all finish needs too long time. If any

How to add token when using axios to send an ajax request?

与世无争的帅哥 提交于 2019-12-23 03:33:15
问题 I am using Laravel 5.3 and vue.js 2.0 , And I use axios (https://github.com/mzabriskie/axios) to send ajax requests, I follow the docs to set the TOKEN like this: <script> axios.defaults.headers.common['Authorization'] = AUTH_TOKEN; //The error is at this line. new Vue({ el: "#app", data: function () { return { items: [] } }, mounted: function () { this.$nextTick(function () { axios.get('/articles').then(function (response) { response.data.forEach(function (item) { item.selected = false; });

Sending array through POST from React App to Spring Boot

微笑、不失礼 提交于 2019-12-23 03:23:13
问题 I've already seen similar question with no success. I need to send a matrix of numbers from a web app (ReactJS) to a Spring Boot controller. I've tried many combination but it always get error, my payload is: {"rows":[[7,0,0,6,4,0,0,0,0],[9,4,0,0,0,0,8,0,0],[0,8,6,2,5,0,0,9,0],[0,0,0,0,6,8,7,3,0],[4,0,8,0,2,1,0,0,0],[0,0,3,0,0,0,1,6,4],[0,0,0,0,0,9,6,7,5],[3,9,0,0,8,5,0,1,2],[0,0,5,0,0,4,0,0,0]]} My react code is: axios.post('http://localhost:8090/api/check', { rows: this.props.rows }) .then

Uploading to Google cloud storage using Signed URL and dropzone ( Vuejs )

孤街醉人 提交于 2019-12-23 02:54:36
问题 I am able to upload to Google cloud storage directly using the below form submission ( after getting signed URL using Nodejs ) <form action="https://<%=fields.bucket%>.storage.googleapis.com" method="post" enctype="multipart/form-data"> <input type="hidden" name="key" value="<%=fields.key%>"> <input type="hidden" name="bucket" value="<%=fields.bucket%>"> <input type="hidden" name="GoogleAccessId" value="<%=fields.GoogleAccessId%>"> <input type="hidden" name="policy" value="<%=fields.policy%>"

Django Rest Framework CORS blocking XMLHttpRequest

不羁的心 提交于 2019-12-23 02:29:27
问题 I have set up my CORS policy using Django-cors-headers with the following settings: APPEND_SLASH=False CORS_ORIGIN_ALLOW_ALL = True CORS_ALLOW_CREDENTIALS = True CORS_ORIGIN_WHITELIST = ( 'localhost:8000', 'localhost:3000', 'localhost' ) I have also added it to installed_apps and middleware. Now I am making a React app for the front end and using AXIOS for my API requests. When I make an API request to log in to my app the CORS policy allows it. But, if I make an API request that requires a

React Laravel - File showing in state but not in controller

好久不见. 提交于 2019-12-23 01:04:41
问题 My project has React as frontend and Laravel as backend. I am trying to upload a file and the details of the file appear in state while uploading but not in the controller and hence not able to upload it in folder. Component has <div className="form-group col-sm-4"> <div className="imgPreview">{$imagePreview}</div> <label>Profile Pic</label> <input className="form-control" type="file" name="profile_pic" onChange={(e)=>this._handleImageChange(e)}/> </div> further codes are: _handleImageChange

React Laravel - File showing in state but not in controller

淺唱寂寞╮ 提交于 2019-12-23 01:04:19
问题 My project has React as frontend and Laravel as backend. I am trying to upload a file and the details of the file appear in state while uploading but not in the controller and hence not able to upload it in folder. Component has <div className="form-group col-sm-4"> <div className="imgPreview">{$imagePreview}</div> <label>Profile Pic</label> <input className="form-control" type="file" name="profile_pic" onChange={(e)=>this._handleImageChange(e)}/> </div> further codes are: _handleImageChange