You are making a request to another site, in this case the API at api.webuntis.dk
. This type of request is called a "Cross Origin Request"
For such requests to work in JavaScript, the server on their end needs to allow them.
This is done by their server sending special CORS headers, the most basic one being the "Access-Control-Allow-Origin" header.
I guess the API provider has not foreseen or planned for this API to be used from a frontend (e.g. JavaScript in the browser), so you would have to work around this.
One way is to set up your own server and have the JavaScript code make a request to your server and your server then making a request to the API, as server side code is not bound to CORS headers.
Alternatively, to try things out, you can prefix the URL with https://cors.io
like this:
const url = 'https://cors.io/?https://api.webuntis.dk/api/status';
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…