Giter VIP home page Giter VIP logo

test_repo_javishub's People

Watchers

 avatar  avatar

test_repo_javishub's Issues

How the ` promise. All ` capture in the wrong?

Summary
I sent several requests, unified handling errors in the interceptor, when I use a promise.all () to send multiple requests, Multiple error prompts are output, whether can unified processing in the interceptor promise.all () the response?

`
ajax.interceptors.response.use((response) => {
if (response.data.access_token) {
Cookies.set('bear', response.data.access_token);
Cookies.set('refresh_bear', response.data.refresh_token);
Cookies.set('expires_in', response.data.expires_in);

teste 5

ALO ALO ALO TESTE TESTE TESTE

can i change the headers['content-type'] before a get request? #1647

our back api limit the request content-type must be an fixed value, even it's a get request.

but i see the source code will remove the content-type when request data is undefined,

so i set an empty data before request, like

if (!config.data) { config.data = "" }
then set the content-type . this will work well on IOS device; but crashed on android device,

it will throw an error,

GET must not have a request body

is there any solution to fix this problem? thanks~

Something wrong when response with code 400 in axios

I'm using Vue and Axios to build a SPA frontend. When server send a response with code 400 in CROS. Browser's console log:

(2) POST http://dev.sportx.one/api/token/ 400 (Bad Request) **This line logged twice**
Failed to load http://dev.sportx.one/api/token/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 400.
Error: Network Error
    at e.exports (spread.js:25)
    at XMLHttpRequest.l.onerror (spread.js:25)

How I send request:

api.request({
 url: '/api/token/',
  method: 'post',
  data: {
    email: '[email protected]',
    password: 'aaaaaaaA'
  }
}).catch(err=>{console.log(err)})

Browser's network inspector shows 2 requests(OPTIONS and POST) has been sent. The both of them are working as expected.

How ever if server send a 20X response without any error catches. Everything is fine.

I try the same code in a new html file and only load axios's script file. Got the same errors.

This question was copied from https://stackoverflow.com/questions/50133379/something-wrong-when-response-with-code-400-in-axios

How the ` promise. All ` capture in the wrong? #6

Summary
I sent several requests, unified handling errors in the interceptor, when I use a promise.all () to send multiple requests, Multiple error prompts are output, whether can unified processing in the interceptor promise.all () the response?

`
ajax.interceptors.response.use((response) => {
if (response.data.access_token) {
Cookies.set('bear', response.data.access_token);
Cookies.set('refresh_bear', response.data.refresh_token);
Cookies.set('expires_in', response.data.expires_in);

Something wrong when response with code 400 in axios

I'm using Vue and Axios to build a SPA frontend. When server send a response with code 400 in CROS. Browser's console log:

(2) POST http://dev.sportx.one/api/token/ 400 (Bad Request) **This line logged twice**
Failed to load http://dev.sportx.one/api/token/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 400.
Error: Network Error
    at e.exports (spread.js:25)
    at XMLHttpRequest.l.onerror (spread.js:25)

How I send request:

api.request({
 url: '/api/token/',
  method: 'post',
  data: {
    email: '[email protected]',
    password: 'aaaaaaaA'
  }
}).catch(err=>{console.log(err)})

Browser's network inspector shows 2 requests(OPTIONS and POST) has been sent. The both of them are working as expected.

How ever if server send a 20X response without any error catches. Everything is fine.

I try the same code in a new html file and only load axios's script file. Got the same errors.

This question was copied from https://stackoverflow.com/questions/50133379/something-wrong-when-response-with-code-400-in-axios

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.