简体   繁体   中英

post request never returning fetch api js

Hello guys I'm trying to make a post request using js fetch api but the problem it's not returning. It never enters the callback in the then function. Can somebody tell me what is it that is going wrong

fetch('http://ready.buzlin.com/buzlinApp/checkout/checkout.php', {
              method: 'POST',
              headers: {
                  'Content-Type': 'application/json',

              },
              body: s
          }).then((response) => {
              console.log("ok");
          });

If I make the same call using postman it works

在此处输入图片说明

This is a CORS problem, a security measure adopted by browsers (which explains why you could do it via Postman).

Basically, your browser sends a preflight request to the server to know what it is expecting, and the server isn't returning your origin as an acceptable one (Access-Control-Allow-Origin Header).

This API probably does not support CORS. That means your request will only work if made from server-side, secure browsers will not allow it.

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