Skip to content

How to retrieve a token when using a client #2326

@enterprisebug

Description

@enterprisebug

I used the following command to create a client with axios.

npx openapi-typescript-codegen --input src/swagger/v1.json --output ./src/apiClients/kineticLinkApi --client axios --name KineticLinkApiClient

I want to create a centralized instance of the client:

import { KineticLinkApiClient } from "@/apiClients/kineticLinkApi";

// When deploying, this should be the public URL of your Next.js app
const NEXTJS_API_BASE_URL = process.env.NODE_ENV === 'production'
  ? process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : 'YOUR_PRODUCTION_NEXTJS_URL'
  : 'https://localhost:7047';


const kineticLinkApiClient = new KineticLinkApiClient({
  BASE: NEXTJS_API_BASE_URL,
  TOKEN: 'Static token is working' // HOW CAN I RETRIEVE A TOKEN FROM SERVER?
});

export default kineticLinkApiClient;

I do not understand how to dynamically fetch a token.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions