hope all are good
I've read some answers about this, and trying different methods to convert a str response from an API, and can't get it work, here's the str response:
'{'status': '200. Ok', 'message': 'Request success'}'
The single quote at the beginning and the end, came from the response, I've tried with JSON.parse and get:
SyntaxError: Unexpected token ' in JSON at position 1
I slice the quotes at the beginning and the end, and get the same result. I even tried to add [] and didn't work either
Here's some code I try:
let response = "'{'status': '200. Ok', 'message': 'Request success'}'"
let setquotes = response.slice(1).slice(0, -1)
let convert_one = JSON.parse(setquotes)
// Got the SyntaxError for single quote
let setkeys = "[" + setquotes + "]"
let convert_two = JSON.parse(setquotes)
Could someone please help me! Thanks very much