import React, { Component } from "react";
class LinkdIn extends Component {
constructor(props) {
super(props);
this.onLinkedInLoad = this.onLinkedInLoad.bind(this);
this.getProfileData = this.getProfileData.bind(this);
this.displayProfileData = this.displayProfileData.bind(this);
this.onError = this.onError.bind(this);
this.onError = this.onError.bind(this);
this.logout = this.logout.bind(this);
}
onLinkedInLoad() {
IN.Event.on(IN, "auth", getProfileData);
}
// Use the API call wrapper to request the member's profile data
getProfileData() {
IN.API.Profile("me")
.fields(
"id",
"first-name",
"last-name",
"headline",
"location",
"picture-url",
"public-profile-url",
"email-address"
)
.result(displayProfileData)
.error(onError);
}
// Handle the successful return from the API call
displayProfileData(data) {
var user = data.values[0];
alert(user.emailAddress);
alert(user.pictureUrl);
alert(user.lastName);
alert(user.headline);
alert(user.location.name);
alert(user.publicProfileUrl);
}
// Handle an error response from the API call
onError(error) {
console.log(error);
}
// Destroy the session of linkedin
logout() {
IN.User.logout(removeProfileData);
}
render() {
return (
<div>
<button onClick={this.onLinkedInLoad}> Login with LinkdIn </button>
</div>
);
}
}
export default LinkdIn;
错误:
./ src / Components / LinkdIn.js第24行:未定义“ IN”
no-undef第24行:未定义'IN'no-undef
第24行:no-undef未定义“ getProfileData”第31行: 未定义“ IN”第31行: 未定义'displayProfileData'no-undef第31行:'onError'为 未定义no-undef第53行:“ IN”未定义
no-undef第53行:未定义'removeProfileData'no-undef搜索关键字以详细了解每个错误。