How does a custom node pass json data from js to HTML

*Everybody is good!Does anyone know how a custom node passes json data from js to HTML

Hi,

This stack overflow answer provides an outline for how the Serial node's edit dialog sends a request to the runtime to get data:

thank you very much!

Hello!By this I mean creating a node that displays the contents of the database, connecting to the database in a js file and getting the data, and then displaying the data in the HTML file of the current node.

This is not quite clear I'm afraid.

In general, remember that your custom node is not, itself, a method of displaying user information.

If your request is something like "how do I read data from a database and display it to a user" then you won't need a custom node unless the "database" is actually something like a web API or an unusual db that doesn't already have a node. You will likely find that a node already exists and you can simply build a flow that gets the data from the db, passes that data to a node that builds a user interface - for example via Dashboard or uibuilder.

If you mean something else, perhaps you could elaborate a little more please.

things1 things2

  • Could you tell me which node you mean by having a node?I need to implement the function design in the same node. As shown in the figure, click the edit button to get the data from the database and display it in the list. The data amount is not large, which is the name of some product list.

things1 things2
I need to implement the function design in the same node. As shown in the figure, click the edit button to get the data from the database and display it in the list. The data amount is not large, which is the name of some product list.

@JiChen

so you need two things:

  1. a custom HTTP endpoint in the runtime (provided by your node's .js file) that does the database look up of the information and returns the list of products

  2. your node's edit dialog to call that HTTP endpoint to retrieve the data and generate the list of options in the edit dialog.

The details of how to create those two things is described in the StackOverflow answer I have given you the link to.

As I have said before, if any part of that StackOverflow answer is not clear, then please ask and we can help make it clearer.

  • Ok, thank you. I know better