I have an Action with optional params that looks like this:
def editLink(storyId: Long, linkId: Long, thumbnail: Option[String], title: Option[String], description: Option[String], hidden: Option[Boolean]) = Action.async { ... }
This action is exposed as a JSRoute. I had assumed that providing null as a param to the javascript route from JavaScript would map to Scala's None, but that appears to be incorrect and, instead, it translates to a literal "null" String. How can I indicate that certain query parameters are None when using this action from JavaScript?
Javascript, this wonderful language has two keywords usually used to define the absence of something. null is one of them, undefined is another one. Knowing that when you omit a parameter in a function, it gets passed as undefined, I would imagine that this is what you should use for an optional parameter. As an example :
var f = function (param, optionalParam) {
console.log(optionalParam);
}
f(1, 2); // prints 2
f(1); // prints undefined
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With