首页 > 解决方案 > 任何人都知道如何使用 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

搜索关键字以了解有关每个错误的更多信息。

标签: javascriptreactjs

解决方案


推荐阅读