I think your issue might just be how you copied the example code? In your code you have:
if (r.method == "POST" && r.query && r.query.led)
But the actual code is:
if (req.method=="POST" && r.query && r.query.led)
I think it'll work fine for you if you do that? Unfortuntely with these big bits of code it's hard to copy everything out without errors. If it's some help, I made the original code available online at https://github.com/espruino/making-things-smart - specifically I think https://github.com/espruino/making-things-smart/blob/master/experiment32.js is what you're after?
@Gordon started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I think your issue might just be how you copied the example code? In your code you have:
But the actual code is:
I think it'll work fine for you if you do that? Unfortuntely with these big bits of code it's hard to copy everything out without errors. If it's some help, I made the original code available online at https://github.com/espruino/making-things-smart - specifically I think https://github.com/espruino/making-things-smart/blob/master/experiment32.js is what you're after?