axios

API Returns Unauthorized when doing a patch from javascript client

∥☆過路亽.° 提交于 2019-12-10 12:14:58
问题 I'm doing a patch to an API that uses Identity Server for authentication. When I run it on Postman the patch works perfectly http://localhost:90909/api/products/3434 Headers = { Authorization: Bearer <token> Content-Type: application/json-patch+json } Body: [ { "op" : "replace", "path" : "/DESCRIPTION", "value" : "bruhhh" } ] But when I execute the patch on my Reactjs using axios it would return Unauthorized: static update(data){ let config = { data : [], headers: { 'Authorization' : 'Bearer

Axios Interceptor Response Token Refresh API called but getting Token is expired regardless in refreshToken API & lator all APIs

夙愿已清 提交于 2019-12-10 11:59:43
问题 my axios interceptor is:- axios.interceptors.response.use((response, error) => { const originalRequest = response.config; if (response.data.status === 'Token is Expired' && originalRequest.url === '/api/refresh') { this.props.history.push('/logout'); Promise.reject(error); } if (response.data.status === 'Token is Expired' && !originalRequest._retry) { originalRequest._retry = true; const playerToken = localStorage.getItem('accessToken'); return axios .get('/api/refresh', { headers: {

Cant display data in datatable using vue axios

左心房为你撑大大i 提交于 2019-12-10 11:51:50
问题 I dont know why my data wont show in my datatable but when I check the console and the vue tool i can see my data. When I compile my js files it wont show me an error. Im just using the datatable and used $('#example').DataTable(); function then i used v-for in the <td> for showing the data. Thanks for the help! Users.vue <table id="example" class="table table-striped table-bordered"> <thead> <tr> <th>Id</th> <th>Name</th> <th>Email</th> <th>Type</th> <th>Created</th> </tr> </thead> <tbody>

React-native POST request in android over https return network error

假如想象 提交于 2019-12-10 11:32:48
问题 Tried to create user account through https POST request under react-native with axios, while it always failed on android with a 'network error'. axios('https://'+DEST_URI, { method: 'post', data: account, headers: { 'Accept': 'application/json', } then(...) The same https POST request works fine on iOS. Changed to http, the same POST request works on android as well. Also tried GET request through https on android, it could retrieve data from the backend server as expected. Any idea about it?

How to Improve The axios.spread

醉酒当歌 提交于 2019-12-10 10:52:43
问题 The below code i use for doing multiple HTTP calls depending on the studentList . It works well; however, I think the axios spread is not necessary export default { getFee (studentList: { studentId: string }[]) { if (studentList.length < 1) { Promise.resolve() } let promises = [] for (const student of studentList) { if (!student.studentId) { Promise.resolve() } var url = `${API_URL}/${student.studentId}` promises.push(Axios.get(url)) } return Axios.all(promises) .then(Axios.spread((...args) =

API requests with axios always unauthorized with Laravel API

杀马特。学长 韩版系。学妹 提交于 2019-12-10 05:18:55
问题 I'm working on a personal project using Laravel 5.6 and Axios library (standard Laravel 5.6 package). I need to send first GET then POST request using Laravel's API and axios' http requests, but I'm not using Passport or any library like that since it's an internal API serving only VueJS to obtain stuff from the database. If I set my API routes using auth:api middleware, I always get unauthorized response, whichever is the request type, this is the error output : Error: Request failed with

process Axios POST in PHP [duplicate]

雨燕双飞 提交于 2019-12-10 01:34:52
问题 This question already has answers here : Issue reading HTTP request body from a JSON POST in PHP (2 answers) Closed last year . I want to send a POST request to my PHP file to handle it and store the data in the database.. I'm pretty stuck at it since $_POST stays empty whatever I try.. Can someone help me sending a post request and help me how to handle it ? My axios request: // Performing a POST request axios.post('dev/api/post.php',{ text: text, unk: unk}) .then(function(response){ console

Vue - Do API calls belong in Vuex?

南楼画角 提交于 2019-12-09 23:00:31
问题 I am struggling with finding answer for where to ideally put API calls in vue modules. I am not building an SPA. For example my auth block has several components for login, password reset, account verifiction etc. Each block uses axios for API calls. Axios already provides promises, which are async. The question is about the best pracitces. Do API calls belong in a Vuex actions? Are there any pros/cons of such approach? Is there any drawback of keeping axios calls within the components they

Axios only called once inside self-invoking function (Internet Explorer)

丶灬走出姿态 提交于 2019-12-09 17:53:44
问题 I have a function that calls itself every 2.5 seconds to check on a task running in the background. It calls axios to get a url if the response is an error, and if the response is successful, I stop the function. This works perfectly on Chrome and in Mozilla but for some reason it doesn't work in IE (version 11). The function calls itself infinitely, but checking the logs show that it only calls axios once, then it has res.data.err == "Task not ready" looping forever, even if the task on back

cross domain at axios

孤人 提交于 2019-12-09 16:32:17
问题 I am changing jquery ajax for axios and I not getting use axios with cross domain: axios.get(myurl, { headers: { 'crossDomain': true }, }).then(res => { console.log(res); }).catch(error => { console.log('erro', error); }) My jquery code is working: $.ajax({ type: 'GET', crossDomain: true, url:myurl, success: (res) => {}, error: (fail) => {} }) The error: Request header field crossDomain is not allowed by Access-Control-Allow-Headers in preflight response. Can anyone help me? 回答1: "crossDomain