i've created an generic request service but it keeps returning 'ZoneAwarePromise'. I've tried to use .pipe() and .subscribe() to try to retrive the content of the request, but it's not working.
requester.service.ts
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class RequesterService {
constructor(private http: HttpClient) { }
request(method, url, headers, body, params) {
return this.http.request(method, url, {
body: body || {},
headers: headers || {},
params: params || {}
})
}
async get(url, params?, headers?, data?) {
return await this.request('get', url, params, headers, data)
}
async post(url, params, headers, data) {
return await this.request('post', url, params, headers, data);
}
async put(url, params, headers, data) {
return await this.request('put', url, params, headers, data);
}
async delete(url, params, headers, data) {
return await this.request('delete', url, params, headers, data);
}
}
gym-list.component.ts
import { Component, OnInit } from '@angular/core';
import { RequesterService } from 'src/app/core/Requester/requester.service';
@Component({
selector: 'app-gym-list',
templateUrl: './gym-list.component.html',
styleUrls: ['./gym-list.component.css']
})
export class GymListComponent implements OnInit {
constructor(private Requester: RequesterService) { }
ngOnInit() {
console.log(this.teste())
}
async teste() {
await this.Requester.get('https://searchs.glitch.me/proposalcontent')
}
}