As others have pointed out, most probably img is in string form. You need to run JSON.parse() on it to convert it to an object, so you can access its properties.

Here I have written the JSON.parse() inside a check i.e. only when img is of type "string" should you parse it. But I think, you will always be getting img as a string, so you can simply parse it without the check.