We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
process
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
export const api = createApi({ baseQuery: fetchBaseQuery({ baseUrl: process.env.REACT_APP_BASE_URL }), reducerPath: "adminApi", tagTypes: ["Mankind"], endpoints: (build) => ({ getUser: build.query({ query: (id) => general/user/${id}, providesTags: ["Mankind"], }), }), });
general/user/${id}
export const { userGetUserQuery } = api;
Please, why these error below when I run npm run dev api.js:5 Uncaught ReferenceError: process is not defined at api.js:5:40 (anonymous) @ api.js:5
The text was updated successfully, but these errors were encountered:
It seems like your bundler doesn't replace process.env.. Most bundlers should do that by default - what are you using?
process.env.
Also, this seems to be an access to process your own code...?
Also, please use a more fitting title. For this problem it doesn't really play a role if you want to create a dashboard or build a rocket.
Sorry, something went wrong.
Since, you are using vite here, and vite has different way of processing the environment variables. So, simply change
export const api = createApi({ baseQuery: fetchBaseQuery({ baseUrl: import.meta.env.VITE_REACT_APP_BASE_URL }), // <---- changed this reducerPath: "adminApi", tagTypes: ["Mankind"], endpoints: (build) => ({ getUser: build.query({ query: (id) => general/user/${id}, providesTags: ["Mankind"], }), }), });
Now, it would work...
No branches or pull requests
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
export const api = createApi({
baseQuery: fetchBaseQuery({ baseUrl: process.env.REACT_APP_BASE_URL }),
reducerPath: "adminApi",
tagTypes: ["Mankind"],
endpoints: (build) => ({
getUser: build.query({
query: (id) =>
general/user/${id}
,providesTags: ["Mankind"],
}),
}),
});
export const { userGetUserQuery } = api;
Please, why these error below when I run npm run dev
api.js:5 Uncaught ReferenceError: process is not defined
at api.js:5:40
(anonymous) @ api.js:5
The text was updated successfully, but these errors were encountered: