• tredstone

    tredstone

    2 years ago
    i'm curios to know more about using a single axios instance on the front end though. i'm going to pull the demo app shortly and take a look at what's going on as well
  • r

    rp

    2 years ago
    So with express, you have two ways to use it - with a middleware and without a middleware.
  • r

    rp

    2 years ago
    If ur using a middleware, you can apply the middleware to certain APIs only (the ones that require authentication). This will allow ur other APIs to be unaffected.
  • r

    rp

    2 years ago
    If your not using middleware, then for the APIs that do not require authentication, u can simple not use any of the SuperTokens functions in it.
  • tredstone

    tredstone

    2 years ago
    makes sense
  • r

    rp

    2 years ago
    Using a single axios instance throughout your frontend would work the exact same way as you would normally use it - except that you have to call SuperTokensRequest.makeSuper(axios) whenever (and immediately after) you import an instance of axios.
  • r

    rp

    2 years ago
    I hope this answers your question. If not, please feel free to ask more
  • tredstone

    tredstone

    2 years ago
    oh i see, call SuperTokensRequest.makeSuper(axios) and use the instance returned from this for the requests that require authentication? i quickly went through the docs once (today when i found the project) so my appologies if the questions sounds basic.
  • r

    rp

    2 years ago
    That function returns nothing. All you have to do is call it. And then continue using axios as u would regularly. See this page (with interceptors section) for an example: https://supertokens.github.io/supertokens-website/docs/axios/sending-requests
  • r

    rp

    2 years ago
    And of course, you also need to call the init function of the library as shown in the link above.