This is the XMLHttpRequest object. When I put it on cosole.log
it gives the following response:
console.log(this.responseText);
"[
{
"url": "https://api.github.com/gists/c7c0df592e99c0c34b99",
"forks_url": "https://api.github.com/gists/c7c0df592e99c0c34b99/forks",
"commits_url": "https://api.github.com/gists/c7c0df592e99c0c34b99/commits",
"id": "c7c0df592e99c0c34b99",
"git_pull_url": "https://gist.github.com/c7c0df592e99c0c34b99.git",
"git_push_url": "https://gist.github.com/c7c0df592e99c0c34b99.git",
"html_url": "https://gist.github.com/c7c0df592e99c0c34b99",
"files": {
"config.json": {
"filename": "config.json",
"type": "application/json",
"language": "JSON",
"raw_url": "https://gist.githubusercontent.com/anonymous/c7c0df592e99c0c34b99/raw/70489beaa4953f89fc8848195371da6eca76164c/config.json",
"size": 17911
}
},
"public": true,
"created_at": "2015-04-26T20:34:11Z",
"updated_at": "2015-04-26T20:34:11Z",
"description": "Bootstrap Customizer Config",
"comments": 0,
"user": null,
"comments_url": "h"[…]
But when I try to use JSON.parse
on it it gives me an error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
.
gists = JSON.parse(this.reponseText)
im supposed to be using this api https://developer.github.com/v3/gists/ and its supposed to return valid json according to that documentation
Is the above data that was returned by the website not valid JSON? Or am I supposed to use a different function other than JSON.parse
? Or what is going on? Please help.
full pastebin here: http://pastebin.com/BWttNtXP