[@bs.val] external envPort: string = “process.env.PORT”
How do I test if envPort is undefined?
Normally I would do const PORT = process.env.PORT || 9000
but that doesn’t work in ReasonML
I know I can also use https://bucklescript.github.io/bucklescript/api/Node.Process.html but the problem is more how one would do it if they had to. And right now if you google it, there is no good results.
https://www.google.com/search?q=process.env.PORT+reasonml
https://www.google.com/search?q=process.env+reasonml
EDIT: An example of how to get a port if defined.
let port = switch(Js.Dict.get(Node.Process.process##env, "PORT")) {
| Some(string) => string
| None => "9000"
};