Kindly wait a moment, post will be visible in just 5 seconds.

No Preview

Rushabh Ramani

Posted on 2 November 2023

AxiosError {message: 'Network Error', name: 'AxiosError', code: 'ERR_NETWORK', config: {…}, request: XMLHttpRequest, …} code : "ERR_NETWORK" config : {transitional: {…}, adapter: Array(2), transformRequest: Array(1), transformResponse: Array(1), timeout

Ad Banner

The api created for the post is working perfectly at the post man but showing bad request at the website :  

const

handleOk

=

()

=>

{   

setIsModalOpen

(

false

);   

const

form

=

new

FormData

();   

form

.

append

(

"name"

,

name

);   

form

.

append

(

"quantity"

,

quantity

);   

form

.

append

(

"price"

,

price

);   

form

.

append

(

"description"

,

description

);   

form

.

append

(

"category"

,

categoryId

);   

for

(

let

pic

of

productPictures

) {    

form

.

append

(

"productPicture"

,

pic

);   }   

dispatch

(

addProduct

(

form

))  }; actions of the product :

import

axios

from

"../helpers/axios"

;

export

const

addProduct

=

(

form

)

=>

{  

return

async

(

dispatch

)

=>

{   

try

{    

const

res

=

await

axios

.

post

(

`product/create`

,

form

);    

console

.

log

(

res

)   }

catch

(

error

) {    

console

.

log

(

error

);   }  }; };

1

53

0

No Preview

Rushabh Ramani

Explore more similar Post

2 Comments

Rushabh Ramani

2 November 2023

this is my github link for further reference : https://github.com/RushabhRamani123/mern_stack_ecommerce_website

0
REPLY

Rushabh Ramani

2 November 2023

working more than 48 hours on same bug please help me out !!

0
REPLY