Hi,
I am attempting to receive a form variable called “position” that is posted from a website. The problem is that the variable needs to be a float between 0.0 and 1.0. I am retrieving the variable inside of a Rocky api post method and attempting to convert that to a string. No matter how I assign the variables it can’t find the toFloat() method on the variable. Here is my code:
api.post("/set-position", function (context){
local postedPosition = null;
#if (!("position" in context.req.body)) {
# context.send(400, { message = "Missing Required Parameter 'position'" });
# return;
#}
postedPosition = context.req.body.position;
local position = postedPosition.toFloat();
server.log("/set-position recevied : " + position);
servo_position = position;
context.send(200, "OK");
});
Thank you!