属性'map'在Angular 6中的'Observable <response>'类型上不存在

时间:2018-07-12 17:23:45

标签: angular

“可观察”类型上不存在“地图”

import { Users } from './../shared/model';
import 'rxjs/add/operator/map';
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/filter';




@Injectable({
  providedIn: 'root'
})
export class LoginService {

  url="http://localhost:3000/api/user";
 users:Users;





  constructor(private http: Http) { }

  getUsers(){
    return this.http.get(this.url);
  }

  // postUsers(users:Users){
  //   return this.http.post(this.url,users);



login(credentials){
  return this.http.post('http://localhost:3000/api/user',JSON.stringify(credentials))
  .map(response=>{
    let result=response.json();
    if(result && result.token){
      localStorage.setItem('token',result.token);
      return true;
    }
   });
  }

即使我也有导入,我也遇到错误.map,但找不到任何解决方法...  属性“地图”在“可观察”类型上不存在

0 个答案:

没有答案