axios

axios IE promise doesn't work

孤者浪人 提交于 2019-11-29 07:32:49
I am using axios for ajax communication. I have problem with IE. IE return error about Promise. IE doesn't know anything about Promise. I am writing react/redux but I tried axios in plain JS and same result Could someone help me with it? I am confused because axios should work on IE 8+ I tried on IE 11 (windows 10 64bit) My trial is written as is in example on axios homepage thx You have to include a promise polyfill if the browser has no promise implementation. This sounds complicated but there are really good libs. The axios docs mention it: axios depends on a native ES6 Promise

Calling locally hosted server from Expo App

£可爱£侵袭症+ 提交于 2019-11-29 07:19:08
问题 I am creating a react-native app and one of the components I have created contains a property which is populated through data coming from an http request. Right now I am hosting the server from my laptop, however I am testing the app on my phone using the Expo app. Since these are two separate devices, the http://localhost:3000 calls are not working and thus I can not tell whether or not my component is properly working. Is there any way for me to run the server on my laptop and set it up so

'Access-Control-Allow-Origin' issue when API call made from React (Isomorphic app)

孤街醉人 提交于 2019-11-29 05:38:55
I'm running into an issue with my isomorphic JavaScript app using React and Express. I am trying to make an HTTP request with axios.get when my component mounts componentDidMount() { const url = 'http://ufc-data-api.ufc.com/api/v3/iphone/fighters/title_holders'; axios.get(url).then( res => { //use res to update current state }) } I am getting a status 200 res from the API, but I am not getting any response data and getting an error in my console XMLHttpRequest cannot load http://ufc-data-api.ufc.com/api/v3/iphone/fighters/title_holders. No 'Access-Control-Allow-Origin' header is present on the

Unable to catch and log the Error response from an axios request

ⅰ亾dé卋堺 提交于 2019-11-29 05:15:34
I am having a axios request in my react application, for which I am following the axios npm docs. This is my axios request axios.post(helper.getLoginApi(), data) .then((response) => { console.log(response); this.props.history.push(from.pathname) }) .catch((error)=> { console.log(error); }) I am able to successfully log the data on a successful request. However When I intentionally produce an error and try to console.log it, I don't get the result logged instead, I just see POST http://localhost:3000/login 401 (Unauthorized) :3000/login:1 Error: Request failed with status code 401 login.js:66

How do you send images to node js with Axios?

拈花ヽ惹草 提交于 2019-11-29 03:30:56
Is there a way to send an array of images (or a single image) to node using axios? the axios code I'm using(I'm using react js on the front end): onFormSubmit(event){ event.preventDefault(); let payload = this.state; console.log("in onFormSubmit!!! with state: ", this.state, "and payload: ", payload); axios.post('/api/art', payload) .then(function(response){ console.log('saved successfully') }); The research I've done suggests that perhaps there isn't a supported way to send image files to node using axios, but this seems strange to me. Is there a way? Here is the way I got this to work

how to cancel/abort ajax request in axios

北战南征 提交于 2019-11-29 01:55:46
问题 I use axios for ajax requests and reactJS + flux for render UI. In my app there is third side timeline (reactJS component). Timeline can be managed by mouse's scroll. App sends ajax request for the actual data after any scroll event. Problem that processing of request at server can be more slow than next scroll event. In this case app can have several (2-3 usually) requests that already is deprecated because user scrolls further. it is a problem because every time at receiving of new data

Automating access token refreshing via interceptors in axios

折月煮酒 提交于 2019-11-29 01:30:40
问题 We've recently discussed an axios' interceptor for OAuth authentication token refresh in this question. Basically, what the interceptor should do is to intercept any response with 401 status code and try to refresh the token. With that in mind, the next thing to do is to return a Promise from the interceptor, so that any request which would have normally fail, would run as nothing happens after a token refresh. The main problem is, that an interceptor checks only the 401 status code, which is

How to configure axios to use SSL certificate?

末鹿安然 提交于 2019-11-28 23:45:20
问题 I'm trying to make a request with axios to an api endpoint and I'm getting the following error: Error: unable to verify the first certificate It seems the https module, which axios uses, is unable to verify the SSL certificate used on the server. When visiting the server with my browser, the certificate is valid and I can see/download it. I can also make requests to the api on my browser through https. I can work around it by turning off verification. This code works. const result = await

Accessing VUE JS's data from Axios

白昼怎懂夜的黑 提交于 2019-11-28 23:25:51
问题 I have a Vue JS (Vuetify) App that makes an ajax request that I would like to populate a div's content with the response, however I am having difficulties accessing the instance's data . All examples I have seen use this to point to the data object, but when I do I get this error Unable to set property 'message' of undefined or null reference The app is quite simple: main.js : import Vue from 'vue' import App from './App.vue' import Vuetify from 'vuetify' Vue.use(Vuetify) new Vue({ el: '#app'

Returning an Axios Promise from function

点点圈 提交于 2019-11-28 21:05:43
问题 Can someone please explain why returning an Axios promise allows for further chaining, but returning after applying a then()/catch() method does not? Example: const url = 'https://58f58f38c9deb71200ceece2.mockapi.io/Mapss' function createRequest1() { const request = axios.get(url) request .then(result => console.log('(1) Inside result:', result)) .catch(error => console.error('(1) Inside error:', error)) return request } function createRequest2() { const request = axios.get(url) return