mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-23 00:03:07 +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,
|
endpoint: string,
|
||||||
responseType: ResponseType = "json",
|
responseType: ResponseType = "json",
|
||||||
): Promise<T> {
|
): Promise<T> {
|
||||||
const req_data = {
|
const req_config = {
|
||||||
auth: this.api_auth,
|
auth: this.api_auth,
|
||||||
responseType: responseType,
|
responseType: responseType,
|
||||||
};
|
};
|
||||||
|
|
||||||
return new Promise<T>((resolve, reject) => {
|
return new Promise<T>((resolve, reject) => {
|
||||||
this.axios
|
this.axios
|
||||||
.get<T>(this.api_url(endpoint), req_data)
|
.get<T>(this.api_url(endpoint), req_config)
|
||||||
.then((response) => resolve(response.data))
|
.then((response) => resolve(response.data))
|
||||||
.catch((reason) => {
|
.catch((reason) => {
|
||||||
console.error(`Failed to query ${endpoint}: ${reason}`);
|
console.error(`Failed to query ${endpoint}: ${reason}`);
|
||||||
|
@ -95,9 +95,13 @@ export class Advent22 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public api_put(endpoint: string, data: unknown): Promise<void> {
|
public api_put(endpoint: string, data: unknown): Promise<void> {
|
||||||
|
const req_config = {
|
||||||
|
auth: this.api_auth,
|
||||||
|
};
|
||||||
|
|
||||||
return new Promise<void>((resolve, reject) =>
|
return new Promise<void>((resolve, reject) =>
|
||||||
this.axios
|
this.axios
|
||||||
.put(this.api_url(endpoint), data)
|
.put(this.api_url(endpoint), data, req_config)
|
||||||
.then(() => resolve())
|
.then(() => resolve())
|
||||||
.catch(reject),
|
.catch(reject),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue