CORS issues with AngularJS

I’m trying to post to a function from AngularJS, and I keep getting CORS errors. I’ve read the following:

And I haven’t come up with anything useful that I understand. I’m currently trying the following (I also am unclear how to format the data itself):

$http({
            url:"https://api.spark.io/v1/devices/<device id>/",
            method: "POST",
            data: {"color":$color},
            withCredentials: true,
            headers: {
                'Content-Type': 'application/json',
                'Authorization': 'Bearer <authentication code>'
            }
            })
    };

Solved my own problem by trying to go to sleep. The issue is with me combining multiple tutorials. withCredentials was the culprit. Removing it enables requests to go through just fine. My function isn’t working right, but that’s a whole other issue.

1 Like