K
Kinde4mo ago
Cobo

Accessing Kinde from Redux store

Hi I am using the react SDK. Is it possible to access the kinde api inside of a redux store/reducer?
3 Replies
IkiTg07
IkiTg074mo ago
Hello, could you elaborate on your use case please ?
Cobo
CoboOP4mo ago
I am abstracting API calls away inside redux thunks, so the React components only have to talk to the redux store without knowing about the API implementation. When I make the API call I would like to provide the user token when calling the backend API client in my Redux thunks.
IkiTg07
IkiTg074mo ago
Hey sorry for the LATE answer. I'm not really familiar with redux but uppon research what I've found is that you should be able to do something like this :
import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";


export const fetchData = () => {
return async (dispatch, getState) => {
// Retrieve the token from state
const { getAccessToken } = getKindeServerSession();
const token = await getAccessToken();

// Rest of the logic

// Dispatch the action
};
};
import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";


export const fetchData = () => {
return async (dispatch, getState) => {
// Retrieve the token from state
const { getAccessToken } = getKindeServerSession();
const token = await getAccessToken();

// Rest of the logic

// Dispatch the action
};
};
Want results from more Discord servers?
Add your server