@orlikfy/angular-api-client
v3.57.0
Published
Client generated by nest-openapi-tools.
Downloads
57
Readme
Orlikfy Angular Api Client
Client generated by nest-openapi-tools.
Libs documentation
nest-openapi-tools
https://www.npmjs.com/package/nest-openapi-tools
openapi-generator
https://github.com/OpenAPITools/openapi-generator
Usage
import {
Configuration,
NearbyGamesApi,
NearbyGamesDTO,
GamesApi,
GameDTO,
} from '@orlikfy/angular-api-client';
async function run() {
const apiConfiguration = new Configuration(
{ basePath: 'http://localhost:3009' },
);
const nearbyGamesApi = new NearbyGamesApi(apiConfiguration);
const gamesApi = new GamesApi(apiConfiguration);
// call endpoint
const nearbyGamesAxiosResponse = await nearbyGamesApi.getNearbyGames();
const nearbyGamesData: NearbyGamesDTO = nearbyGamesAxiosResponse.data;
console.log(nearbyGamesData);
// call another endpoint
const gameAxiosResponse = await gamesApi.getGameById(nearbyGamesData.locations[0].games[0].gameId);
const gameData: GameDTO = gameAxiosResponse.data;
console.log(gameData);
}
Authorization
Obtain JWT Token
According to firebase documentation you can obtain JWT token in below way:
firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idToken) {
// Send token to your backend via HTTPS
// ...
}).catch(function(error) {
// Handle error
});
Add JWT Token to request
const authApiConfiguration = new Configuration({
basePath: 'http://localhost:3009',
accessToken: 'e2be66b9-ff9e-41b5-ba42-f6d95a162fab', // this should be taken from firebase auth
});
const usersApi = new UsersApi(authApiConfiguration);
// just call users endpoints
const myUserResponse = await usersApi.getMyUser();