Node.js 角度4-环回2“;“内部服务器错误”&引用;对象(…)不是函数;

Node.js 角度4-环回2“;“内部服务器错误”&引用;对象(…)不是函数;,node.js,angular,loopback,Node.js,Angular,Loopback,我不知道为什么我会犯这个错误,我遵循了《英雄之旅》的教程 代码: 公共产品http://localhost:3000/api/productos'; // web api的URL 建造师( 私有http:HttpClient, 私有消息服务:消息服务){} getProducts():可观察{ 返回this.http.get(this.productsURL) .烟斗( 轻触(products=>this.log(`fetched heros`)), catchError(this.handl

我不知道为什么我会犯这个错误,我遵循了《英雄之旅》的教程

代码:

公共产品http://localhost:3000/api/productos'; // web api的URL 建造师( 私有http:HttpClient, 私有消息服务:消息服务){} getProducts():可观察{ 返回this.http.get(this.productsURL) .烟斗( 轻触(products=>this.log(`fetched heros`)), catchError(this.handleError('getProducts',[])) ); }

这一点还不清楚。这意味着错误在您的环回中。看看你的服务器,给我们提供更多细节!在与Angular集成之前,首先尝试测试API。这是您的服务器问题。发布您的服务器代码。错误不在环回,我尝试了带有google chrome扩展的api,它工作正常。我无法执行以下操作:从“@angular/core”导入{Injectable};从“@angular/common/http”导入{HttpClient,HttpHeaders};从“rxjs/Observable”导入{Observable}const httpOptions={headers:new HttpHeaders({'Content Type':'application/json'})};@Injectable()导出类产品服务{构造函数(私有http:HttpClient){}getProducts(){返回this.http.get('localhost:3000'+'/api/productos');}}}你能检查一下url吗?“我想是它的产品而不是productos。”
public productsURL = 'http://localhost:3000/api/productos';  // URL to web api

  constructor(
    private http: HttpClient,
    private messageService: MessageService) { }

  getProducts (): Observable<Product[]> {
    return this.http.get<Product[]>(this.productsURL)
      .pipe(
        tap(products => this.log(`fetched heroes`)),
        catchError(this.handleError('getProducts', []))
      );
  }