当前位置: 首页>>代码示例>>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;未经允许,请勿转载。