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


TypeScript Http.request方法代码示例

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


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

示例1: fetchTodos

 private fetchTodos(){
     let request = this.http.request("/api/TodoItems");
     
     request.subscribe((response: Response) => {
         this.todos = response.json().map(todo => new TodoItem(todo.Value, todo.Done, todo.ID))
     }, (error) => alert("Error: " + JSON.stringify(error)));
 }
开发者ID:TinMarkovic,项目名称:Dramazon,代码行数:7,代码来源:TodoService.ts

示例2: executeRequest

 public executeRequest(pObserver, pOpt: RequestOptions) {
     console.log('Start request to ' + pOpt.url);
     let vCurrentContext = this;
     vCurrentContext._modalService.showErrorModal('Start request to ' + pOpt.url);
     this._http.request(new Request(pOpt))
         .timeout(this.vTimeout, {status: 408})
         .subscribe(
             (res) => {
                 pObserver.next(res);
                 pObserver.complete();
             },
             (err) => {
                 switch (err.status) {
                     case 403:
                         // caused by invalid token sent to server
                         // try access once again using refresh token
                         // if still failed redirect to login page
                         pObserver.error(err);
                         break;
                     case 400: // system error
                         pObserver.error(err.json());
                         break;
                     case 500: // functional error
                         pObserver.error(err);
                     default:
                         // throw error
                         pObserver.error(err);
                         break;
                 }
             });
 }
开发者ID:acndavidd,项目名称:iDSP-testAPI,代码行数:31,代码来源:my-http.service.ts

示例3: request

  private request(requestArgs: RequestOptionsArgs, additionalArgs?: RequestOptionsArgs) {
    let opts = new RequestOptions(requestArgs);

    if (additionalArgs) {
      opts = opts.merge(additionalArgs);
    }

    let req:Request = new Request(opts);

    if (!req.headers) {
      req.headers = new Headers();
    }

    if (!req.headers.has('Authorization')) {
      req.headers.append('Authorization', `Bearer ${this.getToken()}`);
    }

    return this._http.request(req).catch((err: any) => {
      if (err.status === 401) {
        this.unauthorized.next(err);
      }

      return Observable.throw(err);
    });
  }
开发者ID:AdrianPasalega,项目名称:mean-blueprints-ecommerce,代码行数:25,代码来源:auth-http.ts

示例4: constructor

    constructor(private http: Http) {

        let opts = new RequestOptions({ method: 'GET' });

        this.http.request('http://127.0.0.1:4001/api/ping', opts)
            .map(x => x.json())
            .subscribe(res => this.apiPing = res.ping);
    }
开发者ID:codetunez,项目名称:electron-skeleton,代码行数:8,代码来源:home.ts

示例5: ngOnInit

 //http://jsonplaceholder.typicode.com/
 // makeRequest():void {
 //     this.loading = true;
 //     this.http.request('http://jsonplaceholder.typicode.com/users')
 //         .subscribe((res:Response) => {
 //             this.data = res.json();
 //             this.loading = false;
 //         });
 // }
 ngOnInit():any {
     this.loading = true;
     this.http.request('http://localhost:3000/data/test-users.json')
         .subscribe((res:Response) => {
             this.data = res.json();
             this.loading = false;
         });
 }
开发者ID:dejan-apaone,项目名称:tut7,代码行数:17,代码来源:route-component.ts

示例6: all

 all(url:string) {
     var options = new RequestOptions({
         method: RequestMethod.Get,
         url: url
     });
     var req = new Request(options);
     return this.http.request(req);
 }
开发者ID:atexo-package,项目名称:atexo-component-dashboard,代码行数:8,代码来源:panel-body-article.provider.ts

示例7: makeRequest

 makeRequest(): void {
   this.loading = true;
   this.http.request('http://jsonplaceholder.typicode.com/posts/1')
     .subscribe((res: Response) => {
       this.data = res.json();
       this.loading = false;
     });
 }
开发者ID:Gitjerryzhong,项目名称:angular2,代码行数:8,代码来源:SimpleHTTPComponent.ts

示例8: signup

    signup(user, opts?: RequestOptionsArgs): Observable<Response> {
        opts = opts || {};
        let url = opts.url ? opts.url : joinUrl(this.config.baseUrl, this.config.signupUrl);
        opts.body = JSON.stringify(user) || opts.body;
        opts.method = opts.method || 'POST';

        return this.http.request(url, opts);
    }
开发者ID:drommc,项目名称:ng2-ui-auth,代码行数:8,代码来源:local.ts

示例9: unlink

 unlink(provider: string, opts: RequestOptionsArgs) {
     opts = opts || {};
     let url = opts.url ? opts.url : joinUrl(this.config.baseUrl, this.config.unlinkUrl);
     opts.body = JSON.stringify({ provider: provider }) || opts.body;
     opts.method = opts.method || 'POST';
     
     return this.http.request(url, opts);
 }
开发者ID:drommc,项目名称:ng2-ui-auth,代码行数:8,代码来源:oauth.ts

示例10: deleteIssue

    deleteIssue(id) {
        let firstHeaders = new Headers();
        firstHeaders.append('Content-Type', 'text/plain;charset=UTF-8');

        return this.http.request(new Request({
            method: APIS.HTTP_METHODS.GET,
            url: APIS.DELETE_ISSUE + id
        })).map(res => res.json());
    }
开发者ID:amitmahida92,项目名称:angular-2-sample-rra,代码行数:9,代码来源:listIssues.service.ts


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