简体   繁体   中英

How to solve the error CORS ? mode: 'no-cors'

const result = await fetch(https://example.com', {
  method: 'POST',
  mode: 'no-cors',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"username": "Jochan","countFollowers": 60001}),
});

I am trying to send a request to a third-party API, an error arrives, how can I solve it? Error: POST https://example.com net::ERR_ABORTED 500 (Internal Server Error) 在此处输入图像描述

you are not authorized to get a response from an API that does not have the appropriate headers set. If it is neither yours API nor public one, you can only try some hacks with CORS proxies from google search

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