You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Kettle/src/ClientContainer.ts

31 lines
793 B

import axios from "axios";
class ClientContainer {
host: string;
token: string;
constructor(host: string, token: string) {
this.token = token;
this.host = host;
// TODO: Consider doing nothing to the host
// Alternatively, make an attempt raw, then make
// an attempt after appending during validation
// This way, weird server configs will work.
if(!host.endsWith("/api/v1")) {
this.host += "/api/v1";
}
}
public async _get(endpoint: string) {
const response = await axios.get(
this.host+endpoint,
{
headers: {'Authorization': 'token '+ this.token}
}
);
return response.data;
}
}
export default ClientContainer;