Vue-JS/Axios Uncaught (in promise) Error: Network Error - javascript

I'm trying out VueJS and ended up having an issue with Axios and post request. I'm not sure is related to CORS (I had some at the beginning) or simply the way I handle the errors.
OPTIONS https://127.0.0.1:1880/api/v1/test-endpoint 0 ()
Uncaught (in promise) Error: Network Error at createError
(createError.js?16d0:16) at XMLHttpRequest.handleError
(xhr.js?ec6c:87)
Error Image
Any idea how I can fix it? I tried with other API online and it works perfectly (that's why I believe is some local setup/config I'm missing, especially with regards to CORS).
Thank you in advance

Related

Vue Axios Uncaught (in promise) GET Request Error

axios.get('localhost:3000/api/event')
.then((response) => {
console.log(response);
});
The above code is being used in one of my Vue files and is retrieving data from a server I have set up and successfully tested endpoints with in Postman. The server is currently running, and I am trying to do a get request (from a separate file folder-my client) from the database. When I try this, I get "Uncaught (in promise) AxiosError \ code: ERR_BAD_REQUEST" in my console.
I have looked through other similar questions: vue axios Uncaught (in promise) Cancel , Vue axios error Uncaught (in promise) Error: Request failed with status code 415 , and others but found either an unsatisfactory answer or no answer at all.
My endpoint is correct, the server is running (I can query that same endpoint with Postman and get the JSONs I desire), and I believe my syntax is correct for the axios code. I would love some help with this please.

Uncaught (in promise) Type Error when trying to fetch for URL

I made a server using Node.js and used the Express framework. Once the server was running, I went to Google Chrome and when to inspect element and went to the console, and typed - fetch('http://localhost:7500'). I was expecting to get the CORS error(Which I wanted) but instead got this:
VM267:1 GET http://localhost:7200/ net::ERR_BLOCKED_BY_CLIENT
VM267:1 Uncaught (in promise) TypeError: Failed to fetch
at <anonymous>:1:1
Is there any way to resolve this error?

Apollo Server : throwing an error inside context always returns an http 400 error on the client

So, i got an apollo server running and an apollo-client in my iOS app.
I'm trying to implement an authentication process. And following apollo's documentation about authorization and authentication, i ended up trying the code they provided :
context: ({ req }) => {
throw new AuthenticationError('you must be logged in');
},
But, while testing the code, i discovered that throwing an error wether it is a javascript one, or an apollo error, it always sends back an http 400 error :
Error: Response not successful: Received status code 400
at new ApolloError (errors.cjs.js:31)
at core.cjs.js:1493
at both (utilities.cjs.js:963)
at utilities.cjs.js:956
at tryCallTwo (core.js:45)
at doResolve (core.js:200)
at new Promise (core.js:66)
at Object.then (utilities.cjs.js:956)
at Object.error (utilities.cjs.js:964)
at notifySubscription (Observable.js:140)
The authentication error is not sent back. Even when i throw a custom error, with custom status code and everything it always returns the same error.
Am i doing something wrong ? Or is this an issue ?
If you do not count on receiving a 401 error code for any downstream tasks, I don't think it is an issue you need to worry about. However, if you do need to receive the expected 401, you can use Apollo Link for error handling. Read about it here: https://www.apollographql.com/docs/react/data/error-handling/#advanced-error-handling-with-apollo-link
If you still cannot fix the problem, browsing through this issue may also be helpful: https://github.com/apollographql/apollo-server/issues/1709
Hope this helps, happy coding :)

Getting error in react while using WebRTC

Am using webRTC in my reactJS app,
so am doing everything in webRTC like i used to do in normal javascript file , but on react when ever i establish a call i get this error
index.js:1540 Uncaught Error: The error you provided does not contain a stack trace.
at S (index.js:1540)
at V (index.js:1792)
at index.js:1807
at index.js:1826
at a (index.js:1371)
and this
Uncaught (in promise) DOMException: The play() request was interrupted by a new load request. somelink
and also only my own streaming are showing , the other peer streaming is not been played

graphqljs - returning error code 400 because of graphql errors

So I sometimes forget to add returned properties to a query i.e.
query {
getSomething(name: "something) // woops forgot to retrieve stuff
}
or I just forget what parameters they take but the web console only returns a very obscure 400 error code, which just looks something like this:
POST http://127.0.0.1:8081/creator/item 400 (Bad Request)
Error: Request failed with status code 400
at createError (createError.js?2d83:16)
at settle (settle.js?467f:18)
at XMLHttpRequest.handleLoad
Uncaught (in promise) Error: Error: Request failed with status code 400
Is there a way to get better details? I know when I do server side testing it gives me the proper details.
All things what you see at the web console is result of JavaScript runtime. I guess, your GraphQL library doesn't parse an answer from server on 4xx codes. You can patch the library or catch the error and parse the answer content. But troubleshooting errors during JavaScript runtime is expensive.
So you need find such errors before compiling. There are tools for that:
During development WebStorm IDE plugin or Visual Studio Code plugin
During building GraphQL eslint plugin

Categories

Resources