LinkedIn-API r_emailaddress not retruning email

Viewed 78

I am useing the linkedin Oauth API(my app is fully working and setup correctly with the scopes r_emailaddress) and I can't seem to return email, I can return it with curl but not with my code,

const userEmail = await fetch("https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))", {
            method: "GET",
            headers: {
                "Authorization": "Bearer " + accessToken,
                "Accept": "application/json"
            }
        });
        const userMail = await userEmail.json();
        console.log(userMail)

this code returns elements: [ { 'handle~': [Object], handle: 'urn:li:emailAddress:8238802378' } ]

should "elements": [{"handle~": {"emailAddress": "example.dev@gmail.com"},"handle": "urn:li:emailAddress:8238802378"}]

1 Answers

LOL, this fixed it userMail.elements[0]["handle~"].emailAddress, thanks to Xrysh✅

Related