mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-12-23 21:22:59 +00:00
fix: Advent22.api_put authorization
This commit is contained in:
parent
bd7bc38954
commit
6012cec657
1 changed files with 7 additions and 3 deletions
|
@ -56,14 +56,14 @@ export class Advent22 {
|
|||
endpoint: string,
|
||||
responseType: ResponseType = "json",
|
||||
): Promise<T> {
|
||||
const req_data = {
|
||||
const req_config = {
|
||||
auth: this.api_auth,
|
||||
responseType: responseType,
|
||||
};
|
||||
|
||||
return new Promise<T>((resolve, reject) => {
|
||||
this.axios
|
||||
.get<T>(this.api_url(endpoint), req_data)
|
||||
.get<T>(this.api_url(endpoint), req_config)
|
||||
.then((response) => resolve(response.data))
|
||||
.catch((reason) => {
|
||||
console.error(`Failed to query ${endpoint}: ${reason}`);
|
||||
|
@ -95,9 +95,13 @@ export class Advent22 {
|
|||
}
|
||||
|
||||
public api_put(endpoint: string, data: unknown): Promise<void> {
|
||||
const req_config = {
|
||||
auth: this.api_auth,
|
||||
};
|
||||
|
||||
return new Promise<void>((resolve, reject) =>
|
||||
this.axios
|
||||
.put(this.api_url(endpoint), data)
|
||||
.put(this.api_url(endpoint), data, req_config)
|
||||
.then(() => resolve())
|
||||
.catch(reject),
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue