Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Unexpected token a in JSON at position

JSON.parse(JSON.stringify(userData))
Comment

Unexpected token W in JSON at position 0

Unexpected token W in JSON at position 0

It's because a simple string (plain text) is returned as the response. The text is not a valid JSON. So when you try to do res.json(), it calls JSON.parse(data). Try and do it with the string you provided, and you will get the same error.

use res.text() instead of res.json()
Comment

Unexpected token W in JSON at position 0

Unexpected token W in JSON at position 0

It's because a simple string (plain text) is returned as the response. The text is not a valid JSON. So when you try to do res.json(), it calls JSON.parse(data). Try and do it with the string you provided, and you will get the same error.

use res.text() instead of res.json()
Comment

Unexpected token W in JSON at position 0

Unexpected token W in JSON at position 0

It's because a simple string (plain text) is returned as the response. The text is not a valid JSON. So when you try to do res.json(), it calls JSON.parse(data). Try and do it with the string you provided, and you will get the same error.

use res.text() instead of res.json()
Comment

syntaxerror: unexpected token f in json at position 0

Check out JSON syntax. https://jsonlint.com/
Comment

Unexpected token < in JSON at position 0

The wording of the error message corresponds to what you get from Google Chrome when you run JSON.parse('<...'). I know you said the server is setting Content-Type:application/json, but I am led to believe the response body is actually HTML.

Feed.js:94 undefined "parsererror" "SyntaxError: Unexpected token < in JSON at position 0"

with the line console.error(this.props.url, status, err.toString()) underlined.

The err was actually thrown within jQuery, and passed to you as a variable err. The reason that line is underlined is simply because that is where you are logging it.

I would suggest that you add to your logging. Looking at the actual xhr (XMLHttpRequest) properties to learn more about the response. Try adding console.warn(xhr.responseText) and you will most likely see the HTML that is being received.
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript copy to clipboard 
Javascript :: how to compare two time in moment js 
Javascript :: server.js 
Javascript :: res.locals in express 
Javascript :: react native apk bundle 
Javascript :: A <Route is only ever to be used as the child of <Routes element, never rendered directly. Please wrap your <Route in a <Routes. 
Javascript :: javascript is radio button checked 
Javascript :: javascript foreach example 
Javascript :: wordpress not loading jquery 
Javascript :: unique element in array 
Javascript :: jquery each response 
Javascript :: how to replace strings with react components 
Javascript :: react state array 
Javascript :: best and fastest encrypt and decrypt value in javascript 
Javascript :: supertest multipart/form-data 
Javascript :: switch case in javascript 
Javascript :: How to fetch API data using POST and GET in PHP 
Javascript :: sort nested data using sort function javascript 
Javascript :: Map in Javascript in LWC 
Javascript :: ionic react use yarn 
Javascript :: check every value in array javascript 
Javascript :: jquery child selector 
Javascript :: js set iframe src 
Javascript :: how to flip a Number in javascript 
Javascript :: axios default baseurl conditional environment 
Javascript :: react native share image 
Javascript :: check how many files in a folder js 
Javascript :: angular passing data to child component 
Javascript :: react router dom private route 
Javascript :: how to find id in array javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =