Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

274
Views
'Access-Control-Allow-Origin' header is present on the requested resource. node backend

I have watched a tutorial to know how redux toolkit work after watching that he uses some online api providing service now when i am using it i need to customize it for my use so i have did change the name and the urls

here is my store.js

    import {configureStore} from '@reduxjs/toolkit'
import {setupListeners} from '@reduxjs/toolkit/query'
import { postApi } from './actions/productAction'

export const store = configureStore({
    reducer:{
        [postApi.reducerPath]:postApi.reducer
    },

    // middleware:(getDefaultMiddleware)=>getDefaultMiddleware().concat(postApi.middleware),

    // middleware is also created for us, which will allow us to take advantage of caching, invalidation, polling, and the other features of RTK Query.
  middleware: (getDefaultMiddleware) =>
  getDefaultMiddleware().concat(postApi.middleware),
})

setupListeners(store.dispatch)

Here i have the action file which is actually taking the action updating state

    import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'

export const postApi = createApi({
    reducerPath:'postApi',//this is unique path which will tell the broweser where it need to store the cookie data
    baseQuery: fetchBaseQuery({
        baseUrl:'',
    }),
    endpoints:(builder)=>({
        getAllPost: builder.query({
            query:()=>({
                url:'http://localhost:5000/api/v1/products',
                method:'GET'
            })
        }),
        getPostById: builder.query({
            query: (id) =>({
                url:`posts/${id}`,
                method:'GET'
            })
        })
    })
})

export const {useGetAllPostQuery,useGetPostByIdQuery} = postApi 

The place where i am calling this function is

import React from 'react'
import {useGetAllPostQuery} from '../../actions/productAction'
// import Card from '../../components/Card';

const HomePage = () => {

  console.log(useGetAllPostQuery())
  const responseInfo = useGetAllPostQuery()

  console.log("the response i am getting is",responseInfo)
  
  return (
    <>
    <h1>Hello worls</h1>
    
  </>
  )
}

export default HomePage

my console where i am getting i dont why this error is coming the request is rejcted at the same time my post man works on that enter image description here

The error expanded image

enter image description here

The actual issue is

enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!