Currently, I am facing a challenge in my Angular2 service where I am attempting to integrate the LinkedIN javascript SDK provided by script linkedin. The functionality is working as expected for retrieving data from LinkedIN, however, I am encountering an issue while trying to set the local function variable with the data received from LinkedIN.
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'))
}
}
My assumption is that the problem lies in setting linkedinInfo = data
, it seems like it is not being stored locally. But I am unsure about how to address this and make it a local variable.