Hi I'm new to this.
I'm trying to get http/https respons, which tells sensor data.
Is there a sample project or code reference for me to get a basic understanding of how to write my own blocks?
Any link is well appreciated.
Hi I'm new to this.
I'm trying to get http/https respons, which tells sensor data.
Is there a sample project or code reference for me to get a basic understanding of how to write my own blocks?
Any link is well appreciated.
The basic URL block from the sensing category can fetch data from an endpoint
![]()
Note - to access an local LAN http server, don't run your script from the standard https site - run it from
http://extensions.snap.berkeley.edu/snap/snap.html
Snap! handbook is here on how to write custom blocks
Please move this: Help with Snap!
Done.
Well, it seems quite different from SnapManual. What I have missed?
No single line of strings.
--
Sorry, I can't embed image in reply
That's because of CORS. It looks like you can't get the snap homepage from Snap! Build Your Own Blocks which is weird. Only the snap devs can fix this.
Yes, this works.
I don't know how to explain it, but here's what CORS is
If you're making requests to localhost, then you don't have to worry about this (unless you're using brave).
If you search CORS on this forum, you'll see we've had to deal with it a lot. To get around it, use a CORS proxy.
So basically, websites don’t really like it when you try and get their content. So you use a cors proxy! My favorite is allorigins.win, which has use instructions on its site.
Thanks, it helps a lot. ![]()