简体   繁体   中英

fetch api change POST request to GET request when send it to the server

在此处输入图片说明

I experienced very weird bug during using fetch API. As the picture above shows, the method property of Request is POST , but fetch send the request using GET method.

Also, among three macbooks, two macbooks(one Catalina beta, one Mojave) experienced the same bug, but one macbook(Mojave) did not. The last one just works perfectly.

All three machines used same Wifi network and same version of Chrome.

Where can I start to solve this bug? Any kind of suggestion will be very helpful. Thanks!

I think you have to check your two urls, it is different

not same url

Look at the log message closely, it says:

 redirected: true 

So you are making a POST request, but the server responds with a redirect response so the browser follows the redirect and makes a GET request to the new URL. This is handled transparently by the fetch API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM