javascript - 任何人都知道如何使用 reactjs 登录 linkdIn
问题描述
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 行:'getProfileData' 未定义 no-undef 第 31 行:'IN ' 未定义 no-undef 第 31 行:'displayProfileData' 未定义 no-undef 第 31 行:'onError' 未定义 no-undef 第 53 行:'IN' 未定义
no-undef 第 53 行:'removeProfileData' 是未定义 no-undef搜索关键字以了解有关每个错误的更多信息。
解决方案
推荐阅读
- parsing - 为 wiki 制作一个更简单的解析器函数
- c++ - 如何在 C++ 中描述文件的绝对路径?
- codesynthesis - 你只能用可解的类型合成吗?
- google-cloud-platform - 改进语音到文本的识别
- javascript - 如何使用 Electron 创建一个真正的自定义安装程序?
- python - 将 python 函数部署到 Azure 函数
- python - 如何在单元测试中传递函数
- python - 提取“全名”字段中最后一个单词的首字母。- Python
- python - 设置 matplotlib 子图的大小
- python-3.x - ValueError:具有多个元素的数组的真值不明确。使用 a.any() 或 a.all