Marked Promise methods as async; const correctness; return reject Promise, if failed.

This commit is contained in:
bradyn
2020-11-15 20:29:28 -06:00
parent bf2f351fa2
commit ef53f9f99c
10 changed files with 2348 additions and 146 deletions

View File

@ -5,7 +5,7 @@ import { IQuery } from './interfaces/query';
export class Client {
static apiUrl: string = `${API_URL}/v${API_VERSION}`;
static get(resource: string, params?: IQuery[] | string): Promise<any> {
static async get(resource: string, params?: IQuery[] | string): Promise<any> {
let url: string = `${this.apiUrl}/${resource}`;
let config: axios.AxiosRequestConfig = {
headers: {
@ -20,6 +20,7 @@ export class Client {
.then(response => {
return response.data[Object.keys(response.data)[0]];
})
.catch(error => Promise.reject(error));
}
private static paramsToQuery(params?: IQuery[]): string {