Friday 21 April 2017

How can I create JS functions dynamically from database records or JSON file

Let's say I want to create a function in node that takes an incoming request and spits back a response based on what is in the incoming request. Now let's say that the actual response of the function needs to be dynamic, either provided by a db or a JSON file. Is there a way to create or populate function structure on the fly? For instance let's say I want some logic, if the request object contains A respond 1, and if the request object contains 2 return B. But again, that logic will be based on whatever is in the database or JSON file. Is such a scenario possible ? Am I thinking about this wrong ?



via user379468

No comments:

Post a Comment