Replies: 1 comment
-
| i solved the problem. Since, my reactjs program can send form-data to usequery mutation. So, it cannot send data to backend program. | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
updateProduct: builder.mutation({
query: ({product_id, productdata}) => ({
url:
/product/${product_id},//url: '/product/24',
method: 'PUT',
body: { productdata },
}),
invalidatesTags: ['Productmgmt']
}),
this is my program. i tried add header. it still cannot pass form-data to backend and backend program can't get url's product_id. I tried using postman apps to send form-data to backend. it is no error.
if i send data to useUpdateProductMutation() in component, backend program will get undefined.
How to solve the problem? Thank you very much.
my program have using post mutation to send data. it is no error.
headers: {
'Content-Type': 'multipart/form-data;'
},
In component send data to updateProduct Mutation:
const [ updateproduct ] = useUpdateProductMutation()
formdata.append("product_name", product.product_name);
formdata.append("product_price", product.product_price);
formdata.append("file", imagefile)
updateproduct(product.product_id, formdata)
version:
nodejs: V20.12.2
"@reduxjs/toolkit": "^2.3.0"
Beta Was this translation helpful? Give feedback.
All reactions