0

I have a JSON response like this

"3928593-236523632-2353253" 

after posting some data to a api.

I am trying to assign that response to a variable.

For example var x = data; (where data is the variable set for the https response in a request call)

but this is giving a error

Now usually i would expect something like

[{test: '2352532352352'}]

and i could of cousre go var x = data.test;

When its not like this, how can i attribute the data to a variable?

Thanks

3
  • 2
    would you please share what kind of error are you getting? Commented Dec 19, 2016 at 0:16
  • 1
    but this is giving a error what error is that giving you? Commented Dec 19, 2016 at 0:17
  • Hi Nishanth, it gives me the error that the variable is not defined. Commented Dec 19, 2016 at 1:56

1 Answer 1

1

Sounds like your just getting a JSON encoded string back as the response, which is totally valid JSON.

let response = JSON.parse('"3928593-236523632-2353253"');

and now

response === "3928593-236523632-2353253"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.