mirror of
https://github.com/r-ca/kidshift-skills.git
synced 2024-10-25 17:14:03 +00:00
トークンを外部から設定できるように
This commit is contained in:
parent
0794b706e4
commit
4ecd1e93e7
|
@ -6,6 +6,7 @@ const TIMEOUT = 5000;
|
||||||
|
|
||||||
class ApiClient {
|
class ApiClient {
|
||||||
private client: AxiosInstance;
|
private client: AxiosInstance;
|
||||||
|
private token: string | null = null;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.client = axios.create({
|
this.client = axios.create({
|
||||||
|
@ -14,12 +15,16 @@ class ApiClient {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setToken(token: string): void {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
private getHeaders(includeToken: boolean): Record<string, string> {
|
private getHeaders(includeToken: boolean): Record<string, string> {
|
||||||
const headers: Record<string, string> = {
|
const headers: Record<string, string> = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
};
|
};
|
||||||
if (includeToken) {
|
if (includeToken) {
|
||||||
const token = 'placeholder_token';
|
const token = this.token;
|
||||||
headers['Authorization'] = `Bearer ${token}`;
|
headers['Authorization'] = `Bearer ${token}`;
|
||||||
}
|
}
|
||||||
return headers;
|
return headers;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user