小编Sho*_*her的帖子

找不到名称“HttpParamsOptions”。角 6

也许有人知道为什么 Angular 不理解 HttpParamsOptions,或者也许有另一种方法来添加请求头和参数。

`public getJobs(options: {page?: number, size?: number} = {}, database: string): Observable <IJobs[]> {
  const headers = new HttpHeaders().set('Dataset-Id', database);
  const params: any = {
       page: options.page || 0,
       size: options.size || 10
     };
 const httpParams: HttpParamsOptions = { fromObject: params } as HttpParamsOptions;
 const headerwithParams = { params: new HttpParams(httpParams), headers: headers };
   return this.http.get<IJobs[]>('/api/jobs', headerwithParams);
}`
Run Code Online (Sandbox Code Playgroud)

request-headers typescript angular6

4
推荐指数
1
解决办法
3235
查看次数

标签 统计

angular6 ×1

request-headers ×1

typescript ×1