I am working with javascript in Meteor and I make an HTTP.get request to an API and receive a response res = {..., content: "access_token=4h378fi243h085giouf245&expires=5180430", data=null}
. As you can see, res.content
is a string but it really represent a nice JSON object {access_token: 4h378fi243h085giouf245, expires: 5180430}
.
Is there a Meteor or Javascript package/easy solution to turn that string into that object?
(I've seen some manual string parsing solutions but that seems hacky, and this seems like something Meteor or Javascript would provide for you.)
EDIT: Doing JSON.parse(res.content) is actually the first thing I tried but it gives me 'Unexpected token a', I'm guessing from 'access_token'. Why would that not work?