'trying to post form using RTK query to nodejs

trying to post to nodejs using RTK query mutation

   **endpoint nodejs i have posted using 
fetch(`const handleAddproduct=()=>{ 
 fetch('http://localhost:9000/api/v1/admin/product/new',{
   method:"POST",
  headers:{"Content-Type":"application/json"},
  body:JSON.stringify(newproduct)
}).then(()=>{
   console.log("new Product added")
 })
 }`*
but while using rtk mutation it's not post 
 const handleAddproduct=async()=>{
   await Addproductnew(createProduct).unwrap()
  .then((payload) => console.log('fulfilled', payload))
  .catch((error) => console.error('rejected', error))
}
  
 *export const productApi = createApi({
  tagTypes: ['Product'],
  reducerPath: 'productApi',
  baseQuery: fetchBaseQuery({ baseUrl: "http://localhost:9000/"  }),
  endpoints: (builder) => ({
    getProduct: builder.query({query:(id)=>createRequest(`api/v1/product/${id}`)}),
    getAllProductsByName: builder.query({query:()=>createRequest(`api/v1/products`)}),
    getOrderAdminByName: builder.query({query:()=>createRequest(`api/v1/admin/orders`)}),
    // AddOrdernew:builder.mutation({query:()=>createProductpost(`api/v1/order/new` )}),
    // Addproductnew:builder.mutation({query:()=>createProductpost(`api/v1/admin/product/new`)}),
    Addproductnew: builder.mutation({
            query: newproductid => ({
                url: 'api/v1/admin/product/new',
                method: 'POST',
                body: {newproductid}    
            }),
        }),
  }),
})***
  


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source