safak / youtube

5.04k stars 5.47k forks source link

AxiosError POST 500 - ERR-BAD-RESPONSE when pay products and redirect to order page - time 1:26:45 in video #93

Open Royal6969 opened 2 years ago

Royal6969 commented 2 years ago

Lama please help me! I got stuck in 1:26:45, when you pay the products and redirect to order page creating the order but ... It isn't redirecting me to order page ... it give me an error which says:

AxiosError {message: 'Request failed with status code 500', name: 'AxiosError', code: 'ERR_BAD_RESPONSE', config: {…}, request: XMLHttpRequest, …}

code: "ERR_BAD_RESPONSE" config: {transitional: {…}, transformRequest: Array(1), transformResponse: Array(1), timeout: 0, adapter: ƒ, …} message: "Request failed with status code 500" name: "AxiosError" request: XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, …}

response: config: {transitional: {…}, transformRequest: Array(1), transformResponse: Array(1), timeout: 0, adapter: ƒ, …} data: {errors: {…}, _message: 'Order validation failed', name: 'ValidationError', message: 'Order validation failed: paymentMethod: Path paymentMethod is required.'} headers: {connection: 'keep-alive', content-length: '391', content-type: 'application/json; charset=utf-8', date: 'Thu, 02 Jun 2022 10:12:14 GMT', etag: '"187-EwTIsCW1BTYuXNYg4bGS5+ldyWw"', …} request: XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, …} status: 500 statusText: "Internal Server Error"

I've spent hours and hours looking for solution in Internet but lot of people have this problem too in other projects... I found lot of possible solutions but everyone I tried ... always fail... https://stackoverflow.com/questions/50950011/axios-post-request-fails-with-error-status-code-500-internal-server-error

Please could you help me?? I really like your project and after all the hours I've been doing it I would like to finish it axios-error-500

0xog3 commented 2 years ago

Have you solved this problem ?

dishant-rana commented 2 years ago

You need to use the CORS middleware and allow your origin to access the data from the backend server.

praagneshpatel commented 2 years ago

yes i have sem problem plaese help me borther i have urgently need because i use this project as my final year in college i am stucking on this problem

Royal6969 commented 2 years ago

Finally, I had a syntax mistake in order model... any relevant issue... just check your code

krys-codes commented 1 year ago

Finally, I had a syntax mistake in order model... any relevant issue... just check your code

where exactly? got the same error : /

Royal6969 commented 1 year ago

Finally, I had a syntax mistake in order model... any relevant issue... just check your code

where exactly? got the same error : /

six month ago since I did this project, so I cant't remember the lines exactly... but what I said, in my personal case, my mistake was in the OrderModel... just watch again the part when Lama create the OrderModel and compare his code with yours