簡體   English   中英

如何修復“錯誤:您在預期流的位置提供了‘未定義’。您可以提供 Observable、Promise、Array 或 Iterable”?

[英]How to fix "Error: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable"?

我在該分頁中使用角材料表不僅在服務器中工作,而且在本地工作正常。 在服務器中,當我打開包含表格的頁面時,數據被推送到表格中,但分頁不起作用並且彈出錯誤

ERROR TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable. at subscribeTo (subscribeTo.js:41) at subscribeToResult (subscribeToResult.js:11) at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._innerSub (mergeMap.js:74) at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._tryNext (mergeMap.js:68) at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._next (mergeMap.js:51) at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:53) at Observable._subscribe (subscribeToArray.js:5) at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe (Observable.js:43) at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (Observable.js:29) at MergeMapOperator.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapOperator.call (mergeMap.js:29)

組件.ts

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;
      }
  }

服務.ts

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)
  }

攔截器

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);
      })
    )
  }
}

我希望數據應該推入表格並且數據應該能夠分頁

注意:此代碼在本地運行良好,僅在服務器中無法按預期運行

實際上錯誤是在材料表分頁器中,當它被刪除時它得到了解決

謝謝大家

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題 您提供了“未定義”的預期流。 您可以提供一個Observable,Promise,Array或Iterable 類型錯誤:您在需要流的地方提供了“未定義”。 你可以提供一個 Observable、Promise、Array 或 Iterable 錯誤類型錯誤:您在需要流的地方提供了“空”。 你可以提供一個 Observable、Promise、Array 或 Iterable 錯誤:“您在需要流的地方提供了 &#39;undefined&#39;。您可以提供 Observable、Promise、Array 或 Iterable。” 在我的身份驗證攔截器中 錯誤您在預期 stream 的位置提供了“未定義”。 您可以提供一個 Observable、Promise、Array 或 Iterable,在 Cognito 中調用 refreshSession 錯誤類型錯誤:您在需要流的地方提供了“未定義”。 您可以在 Angular 服務中提供 Observable、Promise、Array 或 Iterable 類型錯誤:您提供了一個預期流的無效對象。 你可以提供一個 Observable、Promise、Array 或 Iterable Angular:您在需要流的地方提供了一個無效的對象。 你可以提供一個 Observable、Promise、Array 或 Iterable xplat您提供了一個無效的對象,該對象應在其中流。 您可以提供一個Observable,Promise,Array或Iterable material-component-datetime-picker-您在預期為 stream 的地方提供了“未定義”。 您可以提供一個 Observable、Promise、Array 或 Iterable
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM