nesjt之HttpService的总结

883 阅读1分钟

同步:

const reponse = await this.httpService.post(url, body).toPromise()

reponse.data是接口返回的值,可以直接通过return返回


异步:

this.httpService.post(url, body).subscribe((response) => {  if (response.data === 'OK') {    this.service.update(1)   }})

可以在请求结果回来之后做一些相应的操作,不会影响主线程