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


TypeScript HttpClient.configure方法代碼示例

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


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

示例1: constructor

 constructor(private http: HttpClient) {
   http.configure(config => {
     config
       .useStandardConfiguration()
       .withBaseUrl('https://api.github.com/');
   });
 }
開發者ID:ltrain777,項目名稱:skeleton-navigation,代碼行數:7,代碼來源:githubservice.ts

示例2: constructor

  constructor(public httpClient: HttpClient,
    public appState: UIApplication,
    public eventAggregator: EventAggregator) {
    this.appState.info(this.constructor.name, 'Initialized');

    let self = this;
    httpClient.configure(
      config => {
        config
          .withBaseUrl(UIConstants.Http.BaseUrl)
          //.withDefaults({})
          .withInterceptor({
            request(request) {
              appState.info(self.constructor.name, `Requesting ${request.method} ${request.url}`);
              appState.IsHttpInUse = true;
              //request.url = encodeURI(request.url);
              return request;
            },
            response(response) {
              appState.info(self.constructor.name, `Response ${response.status} ${response.url}`);
              appState.IsHttpInUse = false;

              if (response instanceof TypeError) {
                throw Error(response['message']);
              }

              if (response.status == 401) {
                eventAggregator.publish('Unauthorized', null);
              }
              else if (response.status != 200) {
                return response.text()
                  .then(resp => {
                    let json: any = {};
                    let error = 'Network Error!!';
                    try {
                      console.log(resp);
                      json = JSON.parse(resp);
                      if (json.message) error = json.message;
                      else if (json.error) error = json.error;
                      else if (response.statusText) error = response.statusText;
                    } catch (e) { }
                    if (error) throw new Error(error);
                    return null;
                  });
              }
              return response;
            },
            requestError(error) {
              appState.IsHttpInUse = false;
              if (error !== null) throw Error(error.message);
              return error;
            },
            responseError(error) {
              appState.IsHttpInUse = false;
              if (error !== null) throw Error(error.message);
              return error;
            }
          });
      });
  }
開發者ID:sigmaframeworks,項目名稱:sigma-ui-framework,代碼行數:60,代碼來源:ui-http-service.ts

示例3: constructor

	constructor(private http: HttpClient, private observerLocator: ObserverLocator) {
		//localStorage.clear();
		this.contacts = JSON.parse(localStorage.getItem(Constants.STORAGE_CONTACTS));

		if (!this.contacts) {
			http.configure(config => {
				config.useStandardConfiguration().withBaseUrl('https://api.github.com/');
			});
			http.fetch('users')
				.then(response => response.json())
				.then(users => {
					this.contacts = users.map((user: { id: number, login: string, avatar_url: string, type: string }) => {
						let contact = new Contact();
						contact.id = user.id;
						contact.username = user.login;
						contact.email = user.login + "@email.com";
						contact.avatarUrl = user.avatar_url;
						contact.description = user.type;
						contact.checked = false;

						return contact;
					});
					this.contacts = this.contacts.splice(20);

					this.updateStorage();
					this.applyObservers();
				});
		}
	}
開發者ID:ishyfishyy,項目名稱:aurelia-contacts,代碼行數:29,代碼來源:store.ts

示例4: constructor

 constructor(http: HttpClient) {
     http.configure(config => {
         config
             .withBaseUrl("http://localhost:64439/api/");
     });
     this.http = http;
 }
開發者ID:tutaurelia,項目名稱:ItemPicker,代碼行數:7,代碼來源:app.ts

示例5: constructor

 constructor(private httpClient: HttpClient, private oAuthProvider: IOAuthProvider)
 {        
     this.httpClient.configure(config => {
         config.withBaseUrl('http://localhost:19388/api/');   
         config.withDefaults({ mode: 'cors' }); 
     });
 }
開發者ID:GooRiOn,項目名稱:AwesomeCalendar,代碼行數:7,代碼來源:dataService.ts

示例6: constructor

 constructor(private _http: HttpClient, private _eventAggregator: EventAggregator) {
     _http.configure(config => {
         config
             .useStandardConfiguration()
             .withBaseUrl('http://localhost:8080/api/');
     });
 };
開發者ID:JDTLH9,項目名稱:aurelia-kaizen,代碼行數:7,代碼來源:todo-store.ts

示例7: constructor

 constructor(private http: HttpClient) {
   http.baseUrl = 'http://localhost:10000/';
   http.configure(config => config
     .withDefaults({
       credentials: 'include'
     })
   );
 }
開發者ID:sebthieti,項目名稱:jogplayer-online,代碼行數:8,代碼來源:playlist.repository.ts

示例8: constructor

 constructor(httpClient: HttpClient) {
     httpClient.configure(config => {
         config
             .useStandardConfiguration()
             .withBaseUrl('http://localhost:8080/');
     });
     this.httpClient = httpClient;
 }
開發者ID:Diego-Rocha,項目名稱:stack-sample,代碼行數:8,代碼來源:pessoa-service.ts

示例9: constructor

    constructor(http: HttpClient) {
        http.configure(config => {
            config
                .withBaseUrl('http://localhost:5000/api/');
        });

        this.httpClient = http;
    }
開發者ID:adamfur,項目名稱:helix,代碼行數:8,代碼來源:apiservice.ts

示例10: constructor

  constructor(
    private http: HttpClient,
    private config: Configuration) {

    http.configure(client => {
      client
        .useStandardConfiguration()
        .withBaseUrl(config.get("rest.baseUrl").asString());
    });
  }
開發者ID:devkat,項目名稱:calendar,代碼行數:10,代碼來源:rest-client.ts


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