axios: Axios response data with HTML junk and status 200

### Axios return entire HTML source code as response.data with response.status 200

I tried to insert the invalid URL into axios.get() and check what is the response.status and response.data will be generated.

error

I released the response.data return me with an entire HTML source code with 200 response.status

Consider as the similar topic, HTML response is not considered an error?

I don’t see any solution provided with this thread.

May I know how to verify the response as incorrect whenever it return entire HTML source code?

### Context

  • Axios version: 0.16.1
  • Laravel version: 5,4

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 17 (1 by maintainers)

Most upvoted comments

Yes its the react project proxy problem (it proxy to itself)

Στις Δευ, 27 Αυγ 2018 στις 1:54 μ.μ., ο/η 六六 notifications@github.com έγραψε:

I hava similar issue. It is well return on dev but get a index.html on testing or production anyone help???

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/axios/axios/issues/889#issuecomment-416189413, or mute the thread https://github.com/notifications/unsubscribe-auth/AQeV1qi6XUJmVLKA977oxJyMFgjEnjntks5uU8_cgaJpZM4NRjaP .

– Γιάννης Παπαδόπουλος

I have the same issue, @rubennorte nothing is wrong from my API, curl work perfectly.

I fixed the issue because i didn’t write https:// in the basePath

axios.interceptors.response.use(response => {
  return response.headers['content-type'] === 'application/json' ? response : Promise.reject(response);
}, error => Promise.reject(error));