Simple http client using javascript and html (and node)

I wanted a very simple awning control for my iPhone and iPad that mimics my remote.

I’ve put some sample javascript code here:

Would very much like hints on how to improve the approach and get around the CORS issue.

Thanks