Can't access object property, even though it shows up in a console log

后端 未结 30 1765
日久生厌
日久生厌 2020-11-22 06:26

Below, you can see the output from these two logs. The first clearly shows the full object with the property I\'m trying to access, but on the very next line of code, I can\

30条回答
  •  旧巷少年郎
    2020-11-22 06:53

    I just encountered this issue as well, and long story short my API was returning a string type and not JSON. So it looked exactly the same when you printed it to the log however whenever I tried to access the properties it gave me an undefined error.

    API Code:

         var response = JsonConvert.DeserializeObject(string Of object);
         return Json(response);
    

    previously I was just returning:

    return Json(string Of object);
    

提交回复
热议问题