Skip to content

Commit

Permalink
Feat(config-endpoint): Adding v3 config endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Angamanga committed Jun 10, 2021
1 parent e691dd6 commit 8e3e169
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* eslint-disable @typescript-eslint/camelcase */
import axios from 'axios';

export class Config {
backendUrl: string;
token: string;

constructor(backendUrl: string) {
this.backendUrl = backendUrl;
}

async getConfig(id?: string): Promise<unknown> {
try {
const url = id
? `${this.backendUrl}/api/v3/config/${id}`
: `${this.backendUrl}/api/v3/config/`;

const response = await axios.get(url);
return response.data;
} catch (err) {
throw new Error(err);
}
}
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export { getAuthToken } from './auth';
export { Categories } from './categories';
export { getLanguages } from './utils';
export { Posts } from './posts';
export { Config } from './config';

0 comments on commit 8e3e169

Please sign in to comment.