I have a node.js restful server that receives API calls
let method = request.query.method;
I setup a list of available APIs
enum apis {
api_name_1,
api_name_2
}
I want to switch the method I got into the available APIs
switch (method) {
case apis.api_name_1:
response.send("You asked for api 1");
break;
case apis.api_name_2:
response.send("You asked for api 2");
break;
default:
response.send("This method is not supported: " + method);
break;
}
When calling the API like this: api/process?method=api_name_2 , node.js receives is as "api_name_2" (as string) while apis.api_name_2 is equivalent to 1 (enum). How can I convert the name of the api into a "readable" api code for node.js?
Thanks