axios

Axios / JWT post 401 (Mac OS and iOS only) “rest_forbidden”

落爺英雄遲暮 提交于 2020-06-01 05:09:38
问题 I'm working on a Vue app that uses Axios and Wordpress JWT Auth for authentication. Recently I started getting this 401 when trying to post (100% of the time) ...but... only on Mac OS X and iOS . Can you point me in the right direction as to how to troubleshoot this? The error object in Chrome console network is this: {"code":"rest_forbidden","message":"Sorry, you are not allowed to do that.","data":{"status":401}} My post looks like this: https://wordpressroot.ourdomain.com/wp-json/jwt-auth

Get closest parent element by class name in React

懵懂的女人 提交于 2020-05-30 11:28:55
问题 Using React, how do I refer to parent element's closest element with certain classname? Code below: const Skill = props => ( <div className="skill-card"> <div className="skill-header"> <div className="skill-header-text"> <div className="skill-header-img-container"> <img src={require('../../img/projects/skills/' + props.skill.image)} alt={props.skill.name} className="skill-image" /> </div> <div className="skill-heading"><h2 className="skill-name">{props.skill.name}</h2></div> </div> <div

Get closest parent element by class name in React

≯℡__Kan透↙ 提交于 2020-05-30 11:27:05
问题 Using React, how do I refer to parent element's closest element with certain classname? Code below: const Skill = props => ( <div className="skill-card"> <div className="skill-header"> <div className="skill-header-text"> <div className="skill-header-img-container"> <img src={require('../../img/projects/skills/' + props.skill.image)} alt={props.skill.name} className="skill-image" /> </div> <div className="skill-heading"><h2 className="skill-name">{props.skill.name}</h2></div> </div> <div

axios catch doesn't catch error

会有一股神秘感。 提交于 2020-05-30 07:56:31
问题 I'm using axios 0.17.0 with the following code: this.props.userSignupRequest(this.state) .then( res => { console.log(res.data) } ) .catch( err => { this.setState({ errors: err.response }) } ) And the server is set to return a 400 when user signup validation doesn't pass. That also shows up in console: POST 400 (Bad Request) , but the setState is not being executed. Why is that? I also tried console.log(err) and nothing. 回答1: A few issues could be at play, we'll likely need to see more of your

Post request Axios : Network error

人走茶凉 提交于 2020-05-29 05:23:14
问题 I'm using NodeJS for the backend, and ReactJS for the frontend. I've a problem with request Axios network. All my Get request work. But Post request don't work. I have just this error "network error" I created a simple webservice to show you my problem : //Serveur code helloWs : (request:Express.Request, response:Express.Response) => { try { response.send('hello WS !') } catch (error) { console.error(error) response.send('error' + error + 'status : ' + error.response.status) response.end() }

Enable CORS from front-end in React with axios?

坚强是说给别人听的谎言 提交于 2020-05-27 04:57:48
问题 I am using React on the front-end and I'm calling API from another domain which I don't own. My axios request: axios(requestURL, { method: 'GET', headers: { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json', 'Authorization': key, withCredentials: true, mode: 'no-cors', } I keep on getting the same error: CORS header ‘Access-Control-Allow-Origin’ missing. Is this something I can overcome from the frontend? I know for a fact that people use that API so it can't be backend

Enable CORS from front-end in React with axios?

不想你离开。 提交于 2020-05-27 04:56:06
问题 I am using React on the front-end and I'm calling API from another domain which I don't own. My axios request: axios(requestURL, { method: 'GET', headers: { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json', 'Authorization': key, withCredentials: true, mode: 'no-cors', } I keep on getting the same error: CORS header ‘Access-Control-Allow-Origin’ missing. Is this something I can overcome from the frontend? I know for a fact that people use that API so it can't be backend

Axios vs Request

心已入冬 提交于 2020-05-27 03:59:47
问题 I am doing a post request to an URL with some formdata.... I am interested in capturing the "command":"insert" part which is in the response.. when I make a post to an url using AXIOS. I dont get this "command":"insert" part axios.post('https://www.localgov.ie/en/views/ajax', { validation_date_from: "10/10/2017", view_name : "bcsm_search_results", view_display_id : "notice_search_pane", view_path : "bcms/search" }).then(function(response){ console.log( response.data) console.log("------------

Axios vs Request

前提是你 提交于 2020-05-27 03:59:05
问题 I am doing a post request to an URL with some formdata.... I am interested in capturing the "command":"insert" part which is in the response.. when I make a post to an url using AXIOS. I dont get this "command":"insert" part axios.post('https://www.localgov.ie/en/views/ajax', { validation_date_from: "10/10/2017", view_name : "bcsm_search_results", view_display_id : "notice_search_pane", view_path : "bcms/search" }).then(function(response){ console.log( response.data) console.log("------------

How do you verify that a request was made with axios-mock-adapter?

一笑奈何 提交于 2020-05-26 10:43:39
问题 I am using https://github.com/ctimmerm/axios-mock-adapter I would like to know how can I verify that an endpoint was actually called by the system under test. In this example: var axios = require('axios'); var MockAdapter = require('axios-mock-adapter'); // This sets the mock adapter on the default instance var mock = new MockAdapter(axios); // Mock any GET request to /users // arguments for reply are (status, data, headers) mock.onGet('/users').reply(200, { users: [ { id: 1, name: 'John