Angular “如何修复”;错误:您提供了';未定义';预计会有小溪的地方。您可以提供一个可观察的、承诺的、数组的或不可观察的;?

Angular “如何修复”;错误:您提供了';未定义';预计会有小溪的地方。您可以提供一个可观察的、承诺的、数组的或不可观察的;?,angular,loopbackjs,Angular,Loopbackjs,我使用的是角度材质表,因为分页不仅在服务器上有效,而且在本地也很有效。在服务器中,当我打开包含该表的页面时,数据被推入表中,但分页不起作用,错误被弹出 组件技术 getCustomerinfoList(): void { this.adminService.getCustomerinfoList(this.componentName, this.selectedCustomer.customer_id) .subscribe(customerlist => {

我使用的是角度材质表,因为分页不仅在服务器上有效,而且在本地也很有效。在服务器中,当我打开包含该表的页面时,数据被推入表中,但分页不起作用,错误被弹出

组件技术

getCustomerinfoList(): void {
    this.adminService.getCustomerinfoList(this.componentName, this.selectedCustomer.customer_id)
      .subscribe(customerlist => {
        let c_rates = customerlist[0][0].customer_routes;
        this.customers = customerlist;
        this.cust_specificData = c_rates ? JSON.parse(c_rates) : [];
        this.cInfo_dataSource.data = this.cust_specificData
        this.cInfo_dataSource.paginator = this.Routepaginator;
        this.cInfo_dataSource.sort = this.Routesort;
      }
  }
服务台

getCustomerinfoList(actionComponentName: String, customerid: number) {
    const url = `${this.baseURL + actionComponentName}/getCustomerRateAccessories?customer_id=${customerid}&access_token=${this.authService.getAuthToken()}`;
    return this.http.get<any>(url, this.httpOptions)
  }
getCustomerFolist(actionComponentName:String,customerid:number){
const url=`${this.baseURL+actionComponentName}/getCustomerRateAccessories?customer\u id=${customerid}&access\u token=${this.authService.getAuthToken()}`;
返回this.http.get(url,this.httpOptions)
}
拦截器

import { Injectable } from '@angular/core';
import { HttpEvent, HttpInterceptor, HttpHandler, HttpResponse } from '@angular/common/http';

import { Observable } from 'rxjs/Rx';
import 'rxjs/add/observable/throw'
import { tap, catchError } from 'rxjs/operators';


@Injectable()

export class loadingInterceptor implements HttpInterceptor {

  intercept(req: any, next: HttpHandler): Observable<HttpEvent<any>> {

    let loadingContainer: HTMLElement = document.getElementsByClassName('bg-pre-loader').item(0) as HTMLElement

    loadingContainer.style.display = 'flex';

    return next.handle(req).pipe(
      tap(event => {
        if (event instanceof HttpResponse) {
          loadingContainer.style.display = 'none';
        }
      }), catchError((err) => {
        loadingContainer.style.display = 'none';
        return Observable.throw(err);
      })
    )
  }
}
从'@angular/core'导入{Injectable};
从'@angular/common/http'导入{HttpEvent,HttpInterceptor,HttpHandler,HttpResponse};
从'rxjs/Rx'导入{Observable};
导入“rxjs/add/observable/throw”
从“rxjs/operators”导入{tap,catchError};
@可注射()
导出类loadingInterceptor实现HttpInterceptor{
截获(req:any,next:HttpHandler):可观察{
让loadingContainer:HTMLElement=document.getElementsByClassName('bg-pre-loader')。项(0)作为HTMLElement
loadingContainer.style.display='flex';
返回next.handle(req.pipe)(
点击(事件=>{
if(HttpResponse的事件实例){
loadingContainer.style.display='none';
}
}),catchError((err)=>{
loadingContainer.style.display='none';
返回可观察。抛出(错误);
})
)
}
}
我希望数据应该被推入表中,并且数据应该能够分页

注: 该代码在本地运行良好,
只有在服务器中,它并没有按预期工作

实际上,错误出现在物料表分页器中,当它被删除时,已得到解决


谢谢大家

错误在mergeMap中。您在某个工作不正常的地方使用了mergeMap。在这个代码示例中,我没有发现您正在使用mergeMaCheck控制台的
网络
选项卡。HTTP请求的响应可能无效。事实上,我在本地让它工作,但在服务器上它不工作。只有错误弹出我不知道哪里有错误
import { Injectable } from '@angular/core';
import { HttpEvent, HttpInterceptor, HttpHandler, HttpResponse } from '@angular/common/http';

import { Observable } from 'rxjs/Rx';
import 'rxjs/add/observable/throw'
import { tap, catchError } from 'rxjs/operators';


@Injectable()

export class loadingInterceptor implements HttpInterceptor {

  intercept(req: any, next: HttpHandler): Observable<HttpEvent<any>> {

    let loadingContainer: HTMLElement = document.getElementsByClassName('bg-pre-loader').item(0) as HTMLElement

    loadingContainer.style.display = 'flex';

    return next.handle(req).pipe(
      tap(event => {
        if (event instanceof HttpResponse) {
          loadingContainer.style.display = 'none';
        }
      }), catchError((err) => {
        loadingContainer.style.display = 'none';
        return Observable.throw(err);
      })
    )
  }
}