I am trying to get my Angular2 service to use the LinkedIN javascript SDK that is loaded by the script linkedin provides. the functionality works for getting the data and returning it but I can't set the local function variable to the data I got back from linkeidn
export class LinkedInAuthService {
constructor(
) {
}
linkedInAuthorization() {
window['IN'].User.authorize();
window['IN'].Event.on(window['IN'], 'auth', this.getLinkedInUserInfo);
}
getLinkedInUserInfo() {
let linkedinInfo:any;
window['IN']
.API
.Raw()
.url("/people/~:(firstName,lastName,emailAddress,industry,specialties,positions)?format=json")
.result(function(data:any){
console.log(data) //logs data correctly
linkedinInfo = data
});
console.log(linkedinInfo) // undefined
}
AuthLinkedInUserforGlx() {
console.log(localStorage.getItem('linkedinInfo'))
}
}
I think the problem is when I set linkedinInfo = data
it is not setting it locally, just not sure how to make it local