I'm a beginner in Javascript and I have a little problem with the eval() function. So, first I get some data through an API :
const xhr = new XMLHttpRequest();
xhr.open('GET', url, false);
xhr.send(null);
So, at that point, I know that xhr.response is for example :
"{"data":[{"id":41462,"created_at":"2017-11-13 [...]}"
Now, I want to make a dictionary with it, so I do :
var req = eval(xhr.response);
But the console shows me "Uncaught SyntaxError: Unexpected token : at window.onload" at the eval() step. And I don't know really why... any tips ?
JSON.parse()instead ofeval()