当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript HttpRequest.clone方法代码示例

本文整理汇总了TypeScript中@angular/common/http.HttpRequest.clone方法的典型用法代码示例。如果您正苦于以下问题:TypeScript HttpRequest.clone方法的具体用法?TypeScript HttpRequest.clone怎么用?TypeScript HttpRequest.clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/common/http.HttpRequest的用法示例。


在下文中一共展示了HttpRequest.clone方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: intercept

    /**
     * Intercept the http request.
     *
     * @param  req
     * @param  next
     */
    intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
        req = req.clone({
            headers: this.http.headers,
            url: this.http.getUrl(req.url)
        });

        return next.handle(req);
    }
开发者ID:ngKit,项目名称:ngKit,代码行数:14,代码来源:http-interceptor.ts

示例2: intercept

 intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
   var token = localStorage.getItem('token'); //1
   var newHeader: HttpHeaders = req.headers; //2
   newHeader = newHeader.set('Content-Type', 'application/json'); //3
   if(token) newHeader = newHeader.set('x-access-token', token); //4
   const newReq = req.clone({headers: newHeader}); //5
   return next.handle(newReq); //6
 }
开发者ID:wjs991,项目名称:dev_center,代码行数:8,代码来源:request-interceptor.service.ts

示例3: intercept

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

    request = request.clone({
      setHeaders: {
        Authorization: `Bearer ${this.token}`
      }
    });
    return next.handle(request);
  }
开发者ID:joergkrause,项目名称:mvc2ng,代码行数:9,代码来源:tokeninterceptor.service.ts

示例4: intercept

 intercept(req: HttpRequest<any>, next: HttpHandler):
   Observable<HttpEvent<any>> {
     console.log("interceptor: " + req.url);
     req = req.clone({
       withCredentials: true
     });
     
     return next.handle(req);
 }
开发者ID:RickStrahl,项目名称:AlbumViewerVNext,代码行数:9,代码来源:httpRequestInterceptor.ts

示例5: intercept

  intercept(request: HttpRequest<any>, next: HttpHandler):
    Observable<HttpEvent<any>> {
    const url = environment.origin + request.url;
    const updatedRequest = request.clone({
      url: url
    });

    return next.handle(updatedRequest);
  }
开发者ID:avosalmon,项目名称:angular5-ngrx-sample,代码行数:9,代码来源:url-interceptor.ts

示例6: mergeMap

   mergeMap((headersWithBearer) => {
   const kcReq = req.clone({ headers: headersWithBearer });
   return next.handle(kcReq)
     .pipe(
       catchError((error) => {
           return observableThrowError(error);
       })
     );
 })
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:9,代码来源:auth-bearer.interceptor.ts

示例7: intercept

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

    request = request.clone({
        setHeaders: {
            Authorization: 'SharedKey aneesphotostore:'
        }
    });
    return next.handle(request);
    }
开发者ID:aman6129,项目名称:AneesPhotography,代码行数:9,代码来源:image-store.interceptor.ts

示例8: intercept

 intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
   const JWT = `Bearer ${this.token}`;
   req = req.clone({
     setHeaders: {
       Authorization: JWT
     }
   });
   return next.handle(req);
 }
开发者ID:bwhiting2356,项目名称:fiits,代码行数:9,代码来源:jwt.interceptor.ts

示例9: intercept

  intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
    // TODO: Get token from users service
    const token = 'Bearer yXuIbM4Fdr7yE3AAQFEM21ckiyqEpARUgPSQO5dOqZjf587xyq2At8QzQVuC';
    const updatedRequest = request.clone({
      headers: request.headers.set('Authorization', token)
    });

    return next.handle(updatedRequest);
  }
开发者ID:avosalmon,项目名称:angular5-ngrx-sample,代码行数:9,代码来源:auth-interceptor.ts

示例10: intercept

 intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
     if(req.headers.get('Authorization') === null){
         const authHeader = localStorage.getItem('token');
         const authReq = req.clone({ headers: req.headers.set('Authorization', 'Bearer ' + authHeader) });
         return next.handle(authReq);
     } else {
         return next.handle(req);
     }
 }
开发者ID:CFSystems,项目名称:ccpeasyform-ui,代码行数:9,代码来源:auth-interceptor.ts


注:本文中的@angular/common/http.HttpRequest.clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。