@orlikify/angular-api-client

1.12.0 • Public • Published

Orlikify 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 '@orlikify/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();

Readme

Keywords

none

Package Sidebar

Install

npm i @orlikify/angular-api-client

Weekly Downloads

19

Version

1.12.0

License

ISC

Unpacked Size

102 kB

Total Files

45

Last publish

Collaborators

  • krulig