I try to connect my device with api, the device with which I´m able to turn on and of led in the IoT cloud dashboard. I have used example code from javascript arduino iot npm package.
I used browserify and threw html and bundle.js to my school serverfolder used in website making practises.
I got this error message, and I really need help how to fix the cors thing and also how can I send button events, I mean light the led, and turn the led off commands through this IoT Cloud API?
Docs were really weird only telling about adding devices on a command and other bigger stuff.
Not sending everyday user events.
Uncaught TypeError: Cannot read property 'fn' of undefined
at util.js:55
at bootstrap.min.js:6
at bootstrap.min.js:6
(anonymous) @ util.js:55
(anonymous) @ bootstrap.min.js:6
(anonymous) @ bootstrap.min.js:6
index.html:1 Access to fetch at '
https://login.arduino.cc/oauth/token' from origin '
http://sharewell.fi' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
bundle.js:24 Failed getting an access token: RequestError: TypeError: Failed to fetch
getToken @ bundle.js:24
async function (async)
getToken @ bundle.js:20
run @ bundle.js:32
1.@arduino/arduino-iot-client @ bundle.js:42
o @ bundle.js:1
r @ bundle.js:1
(anonymous) @ bundle.js:1
bundle.js:97604 Cross-Origin Read Blocking (CORB) blocked cross-origin response
https://login.arduino.cc/oauth/token with MIME type application/json. See
https://www.chromestatus.com/feature/5629709824032768 for more details.
ClientRequest._onFinish @ bundle.js:97604
(anonymous) @ bundle.js:97525
emitNone @ bundle.js:82948
emit @ bundle.js:83033
finishMaybe @ bundle.js:100240
afterWrite @ bundle.js:100086
Item.run @ bundle.js:92390
drainQueue @ bundle.js:92360
setTimeout (async)
runTimeout @ bundle.js:92278
process.nextTick @ bundle.js:92380
exports.setImmediate @ bundle.js:101097
Request.init @ bundle.js:49865
RP$initInterceptor @ bundle.js:44976
Request @ bundle.js:49469
request @ bundle.js:45347
getToken @ bundle.js:20
run @ bundle.js:32
1.@arduino/arduino-iot-client @ bundle.js:42
o @ bundle.js:1
r @ bundle.js:1
(anonymous) @ bundle.js:1
index.html:1 Access to XMLHttpRequest at '
http://api2.arduino.cc/iot/v2/devices' from origin '
http://sharewell.fi' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.