在Angular 6中使用LinkedIN API“找不到模块:错误:无法解析'rxjs / add / operator / switchMap'”

Ene*_*sxg 1 api linkedin rxjs angular angular6

我试图在Angular应用程序中对LinkedIN API进行简单的API调用。我的API密钥以及所有这些都是完美的。由于某些原因,当我的应用程序调用此函数时,出现以下错误:“未找到模块:错误:无法解析'rxjs / add / operator / switchMap”

我什至添加了这一行:

import 'rxjs/add/operator/switchMap';
Run Code Online (Sandbox Code Playgroud)

到此组件的顶部。

这是我的component.ts总计:

import { Component } from '@angular/core';
import { LinkedInService } from 'angular-linkedin-sdk';
import 'rxjs/add/operator/switchMap';


@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent  {
  title = 'LItest';
  public apiKey;
  private basicProfileFields = ['id', 'first-name', 'last-name', 'maiden-name', 'formatted-name', 'phonetic-first-name', 'phonetic-last-name', 'formatted-phonetic-name', 'headline', 'location', 'industry', 'picture-url', 'positions'];
  public lastResponse;


  public constructor(private _linkedInService: LinkedInService) {
  }

  public rawApiCall(){
    const url = '/people/~?format=json';
    this._linkedInService.raw(url)
      .asObservable()
        .subscribe({
          next: (data) => {
            console.log(data);
          },
          error: (err) => {
            console.log(err);
          },
          complete: () => {
            console.log('RAW API call completed');
          }
        });
  }
}
Run Code Online (Sandbox Code Playgroud)

Saj*_*ran 5

尝试安装

npm install --save rxjs-compat