當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript aurelia-http-client.HttpClient類代碼示例

本文整理匯總了TypeScript中aurelia-http-client.HttpClient的典型用法代碼示例。如果您正苦於以下問題:TypeScript HttpClient類的具體用法?TypeScript HttpClient怎麽用?TypeScript HttpClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了HttpClient類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: convert

  public convert(): Promise<void> {

      if (!this.rawSql)
          return;

      return this
          .client
          .createRequest("/api/sql/format")
          .asPost()
          .withHeader('Content-Type', 'text/plain')
          .withContent(this.rawSql)
          .send()
          .then(r => {

              var result = JSON.parse(r.response);
              this.formattedSql = result.Sql;
              this.timeTaken = result.Duration;
              this.showFormattedSql = true;
          })
          .catch(r => {

              console.log(r.response);
              this.showNotification({ message: r.response, type: "error" });
              this.showFormattedSql = false;
          });
  }
開發者ID:benlaan,項目名稱:sqlformat,代碼行數:26,代碼來源:app.ts

示例2: getFunnyPosts

 getFunnyPosts() : Promise<IRedditPosts> {
   return this.http.jsonp('http://reddit.com/r/funny.json', 'jsonp')
     .then(response => { 
         this.funny = response.response.data.children;
         return this.funny;
     });
 }
開發者ID:ltrain777,項目名稱:skeleton-navigation,代碼行數:7,代碼來源:redditservice.ts

示例3: getGifPosts

 getGifPosts() : Promise<IRedditPosts> {
   return this.http.jsonp('http://reddit.com/r/gifs.json', 'jsonp')
     .then(response => { 
         this.gifs = response.response.data.children;
         return this.gifs;
     });
 }
開發者ID:ltrain777,項目名稱:skeleton-navigation,代碼行數:7,代碼來源:redditservice.ts

示例4: activate

 activate(params: any) {
     return this.http.get(`/api/schedulers/${params.schedulerName}/jobs/history`).then(response => {
         let model = response.content;
         this.entries = model.historyEntries;
         this.errorMessage = model.errorMessage;
     });
 }
開發者ID:Indifer,項目名稱:quartznet,代碼行數:7,代碼來源:history.ts

示例5: Promise

    return new Promise((resolve) => {

      let requestPromise = this.httpClient.createRequest(this.api.read)
        .withParams(options.params || {})
        .send();

      requestPromise.then(response => {
        let result = this.getReader().read(response.content);
        resolve({
          type: 'read',
          success: true,
          data: result.data,
          total: result.total,
          page: result.page,
          limit: result.limit,
          offset: result.offset
        });
      });

      requestPromise.catch(() => {
        resolve({
          type: 'read',
          success: false
        });
      });
    });
開發者ID:black-tree,項目名稱:data,代碼行數:26,代碼來源:http-adapter.ts

示例6: createPost

  createPost(text: string, options: any) {
    this.ea.publish(new ApiStatus('Creating Post', { status: 'info' }));
    var jsonText = {
      text: text,
      entities: {
        parse_links: true,
        parse_markdown_links: true
      },
      reply_to: 0
    };
    if (options.reply_to) { jsonText.reply_to = options.reply_to; }
    this.isRequesting = true;

    return this.http.configure((x: any) => {
      x.withHeader('Authorization', 'Bearer ' + this.state.token);
      x.withHeader('Content-Type', 'application/json');
    }).post(`https://api.app.net/posts`, jsonText)
      .then((response: any) => {
        this.meta = response.content.meta;
        this.isRequesting = false;
        this.ea.publish(new ApiStatus('Post Created', { status: 'success' }));
        return response.content.data;

      }).catch((err: any) => {
        this.isRequesting = false;
        this.ea.publish(new ApiStatus('Unable to post', { status: 'error' }));
        return {};
      });
  }
開發者ID:mttmccb,項目名稱:dark_social,代碼行數:29,代碼來源:adn-api.ts

示例7: getGoogleLoginUrl

 public getGoogleLoginUrl(redirectUrl: string) : Promise<string> {
     return this.httpClient
         .createRequest(`Authentication/Login/Google/Url?redirectUrl=${encodeURIComponent(redirectUrl)}`)
         .asGet()
         .send()
         .then(response => response.content.url)
         .catch(response => Promise.reject(response.content.message));
 }
開發者ID:LeagueLogbook,項目名稱:LogbookWebsite,代碼行數:8,代碼來源:authentication-api.ts

示例8: activate

 activate(params: any) {
   var teamId = params.id;
   
   return this.httpClient.get('./team/'+teamId)
     .then(response => {
       this.team = new TeamViewModel(response.content);
     });
   
 }
開發者ID:richardnagle,項目名稱:buildjs,代碼行數:9,代碼來源:team.ts

示例9: nameChanged

 nameChanged(newValue) {
     if (newValue.length > 0) {
         this.httpClient.get('/hello/' + newValue).then((response) => {
             this.result = response.content.Result;
         });
     } else {
         this.result = '';
     }
 }
開發者ID:KevinHoward,項目名稱:ServiceStackVS,代碼行數:9,代碼來源:hello.ts

示例10: getSummoners

 public getSummoners(token: JsonWebTokenModel): Promise<Summoner[]> {
     return this.httpClient
         .createRequest("Summoners")
         .asGet()
         .withHeader("Authorization", `Bearer ${token.token}`)
         .send()
         .then(response => response.content)
         .catch(response => Promise.reject(response.content.message));
 }
開發者ID:LeagueLogbook,項目名稱:LogbookWebsite,代碼行數:9,代碼來源:summoners-api.ts


注:本文中的aurelia-http-client.HttpClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。