Skip to content

Commit

Permalink
access token
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliohome committed Oct 8, 2023
1 parent 146457d commit 1f8987d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/web/src/services/restService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios, { AxiosInstance } from 'axios';
import { useAuth0, withAuthenticationRequired } from "@auth0/auth0-react";

export interface QueryOptions {
top?: number;
Expand All @@ -21,9 +22,19 @@ export abstract class RestService<T extends Entity> {
}

public async getList(queryOptions?: QueryOptions): Promise<T[]> {
const {
getAccessTokenSilently,
loginWithPopup,
getAccessTokenWithPopup,
} = useAuth0();
const token = await getAccessTokenSilently();
const response = await this.client.request<T[]>({
method: 'GET',
data: queryOptions
data: queryOptions,
headers: {
Authorization: `Bearer ${token}`,
}

});

return response.data;
Expand Down

0 comments on commit 1f8987d

Please sign in to comment.