#Unable to access promise property

6 messages · Page 1 of 1 (latest)

turbid yoke
#

Hello, I am new to Typescript and am having a problem. I have a async/await method and what is interesting is that I get a response back, and that response has a value, but when I try to access that value it says undefined. What am I doing wrong?

await client.Get<User>("/users?$filter=startswith(redacted)").then(user => {
const userId = user[0].id;
client.Get<string>(/users/${user[0].id}/mailFolders)
})

user will be defined and show properties. but when I try to assign UserID equal to one of those properties, that variable is undefined.

fathom patrol
#
await client.Get<User>("/users?$filter=startswith(mail%2C+'mailscan')").then(user => {
    const userId = user[0].id;
    client.Get<string>(/users/${user[0].id}/mailFolders)
})```
#

formatted it ... thinking for solution

turbid yoke
#

Hi @fathom patrol thank you for your response, it turned out to be that the user response was really missing another property. For example, user.value[0].id

fathom patrol
#

!resolved

fathom patrol