axios

Firefox fails on CORS resource, while Chrome and Safari work

狂风中的少年 提交于 2019-12-20 04:17:16
问题 I have a seemingly correct resource backed by a CouchDB installation. Requests are made using JS Axios. Both Chrome and Safari work, Firefox 65.0 fails however with CORS header 'Access-Control-Allow-Origin' does not match 'http://localhost:8080, *' The server (CouchDB) does, in fact, not deliver 'http://localhost:8080, *' as Access-Control-Allow-Origin but Access-Control-Allow-Origin http://localhost:8080 Access-Control-Expose-Headers content-type, cache-control, a…e-newrev, x-couchdb-body

Combine Nodejs + React Native + Axios + CORS

时光毁灭记忆、已成空白 提交于 2019-12-20 02:47:13
问题 I am trying to make a request to my API (Node.JS) from the front-end (react-native) using Axios. But I am confused about the error I get. Here's the print stack trace of the error : Network Error - node_modules\axios\lib\core\createError.js:16:24 in createError - node_modules\axios\lib\adapters\xhr.js:87:25 in handleError - node_modules\event-target-shim\lib\event-target.js:172:43 in dispatchEvent - node_modules\react-native\Libraries\Network\XMLHttpRequest.js:554:29 in setReadyState - node

Chrome: Invoking 'alert()' during microtask execution is deprecated and will be removed

ぃ、小莉子 提交于 2019-12-20 02:32:22
问题 While working on my web app, specifically file uploads, Chrome displayed a warning after I called an alert: Invoking 'alert()' during microtask execution is deprecated and will be removed in M53, around September 2016. See https://www.chromestatus.com/features/5647113010544640 for more details. However I think that in my situation the call is justified and am a little worried my code won't work once M53 is released. Note that I'm not shipping to production with the alerts, but for testing it

My implementation of debounce axios request left the promise in pending state forever, is there a better way?

和自甴很熟 提交于 2019-12-20 01:57:11
问题 I need a simple debounce function with immediate always true. Without resorting to lodash and with the help of Can someone explain the "debounce" function in Javascript , I implemented it as following, function debounce(func, wait) { var timeout; return function() { if (!timeout) func.apply(this, arguments); clearTimeout(timeout); timeout = setTimeout(()=>{timeout = null}, wait); }; }; It works as expected until I need to debounce axios request. Assumed I have a debounced axios method, I

Is there any alternative to CORS google chrome extension? How to make successful ajax request without using CORS?

喜欢而已 提交于 2019-12-19 12:07:24
问题 Hi I have build Udemy API that fetches the courses using React and axios. It works fine if the chrome has CORS extension turned on but otherwise it does not fetch the data. I have already asked a question regarding this issue, please take a moment to read. I have tried all the solutions provided online.. Thanks Related issue: Failed to load resource. Origin is not allowed by Access-Control-Allow-Origin 回答1: This problem usually related with the backend server, but if you don't have an access

Access sibling service from docker container's service

别等时光非礼了梦想. 提交于 2019-12-19 11:52:51
问题 I run Node image based docker container (Docker quickstart terminal from Windows) FROM node:7.8.0 ENV NPM_CONFIG_LOGLEVEL warn VOLUME /tmp #copy server source /piu contains node server and /piu/client contains react+redux client ADD piu /piu ADD server_start.sh / #clean windows \r char to make the .sh file real executable RUN sed -i -e 's/\r$//' server_start.sh CMD ./server_start.sh EXPOSE 3000 3009 I start Node client (on port 3000) and Node (express based) server (on 3009 port). Client

Res.download() working with html form submit but not an Axios post call

笑着哭i 提交于 2019-12-19 10:58:16
问题 I am writing a small app that submits information from a React app to an Express server's "/download" API where it then writes a new file to the local file system and downloads the newly created file on the client side using the Express res.download() in the fs.writeFile() callback. I've been using a regular html form submit to post the data but due to an increase in complexity I've switched over using Axios and it's no longer working. The strange thing is only the download on the client side

body data not sent in axios request

南笙酒味 提交于 2019-12-19 07:52:02
问题 I am trying to send data through axios request to my backend script, but the body looks empty. Here's a request sent from front-end: axios.request({ method: 'GET', url: `http://localhost:4444/next/api`, headers: { 'Authorization': token }, data: { next_swastik: 'lets add something here' }, }).then((res)=>{ console.log("api call sucessfull",res); }).catch((err)=>{ console.log("api call unsucessfull",err); this.props.toggleLoading(false); }) Here's a back-end: app.get('/next/api', verifyToken,

body data not sent in axios request

橙三吉。 提交于 2019-12-19 07:51:02
问题 I am trying to send data through axios request to my backend script, but the body looks empty. Here's a request sent from front-end: axios.request({ method: 'GET', url: `http://localhost:4444/next/api`, headers: { 'Authorization': token }, data: { next_swastik: 'lets add something here' }, }).then((res)=>{ console.log("api call sucessfull",res); }).catch((err)=>{ console.log("api call unsucessfull",err); this.props.toggleLoading(false); }) Here's a back-end: app.get('/next/api', verifyToken,

axios interceptors response undefined

不羁岁月 提交于 2019-12-19 03:38:09
问题 I'm trying to logout my user once they get a 401. I'm using axios to return data from the api I was looking around and found the same axios.interceptors.response axios.interceptors.response.use( response => response, error => { const {status} = error.response; if (status === 401 ) { store.dispatch('snackBar', snackbarObj) } return Promise.reject(error); } ) It appears my error.response is undefined. I'm not sure what is wrong? any ideas? 回答1: You're not getting a response from the request you