How to parse response from server?

Hello,
I get responce from server’s site as string :

{“data”:[“http://site.com/storage/images/file.png”]}

How is the right way to parse it and to have full path and file name ? - as I can not change server’s side.

Thanks!

const data = JSON.parse(response); //assuming the string you posted is in a variable called response
const image = data.data[0];

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse

3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.