Back

[RESOLVED] Function doesn't parse json data

  • 0
  • Functions
  • Web
AndrewIAm
19 Feb, 2023, 09:36

I have an Appwrite function (using Nodejs runtime) which should get user's data from 3rd party source and then create user in Database. For getting user's data the code is: const user = await axios.get(URL, params) My problem is I can not access to the user's object data after getting response. Consoling the user type shows me object but trying to get user.email output nothing. This filed definately exists, I've checked it with Postman app. So my Axios get requiest config is correct. And response fromat is json.

I'm also tryied to initialize user with and empty object and return data even it empty. But running function falls into error: TypeError: Converting circular structure to JSON.

Probably I have another way to get user's data logged in through OAuth login? Simply, I want to save logged user into Database.

TL;DR
Issue: The function is unable to access user data after making a GET request using Axios. The user object appears to be an empty object or a circular structure. Potential Solution: It seems that the Axios response is causing the circular structure error. To access the user's data, try console logging `response.data` instead of `user`. This should log the data retrieved from the GET request, which includes the user's email.
AndrewIAm
19 Feb, 2023, 09:37

Function doesn't parse json data

Drake
19 Feb, 2023, 15:57

I believe the axios.get() returns a Response which contains a lot of stuff that leads to a circular reference. Try:

TypeScript
const response = await axios.get(...);
console.log(response.data);
AndrewIAm
19 Feb, 2023, 19:53

You are absolutely right. Sorry for my distraction

AndrewIAm
19 Feb, 2023, 19:54

[RESOLVED] Function doesn't parse json data

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more