To get the data from a form, you have to have a click event function on a button, or in your case add a function to the change or key-up events (see the Vue documentation on how to call a function on an HTML event and what data that gives you).
In that function, you call the uibuilder.send(msg) function where msg is a msg-like object, for example:
this.msgInput gives you access to the msgInput variable that should be defined in the data property of your Vue app.
Change your uibuilder output debug node to show the whole msg rather than just the payload if you want to see everything.
Finally, you've connected you db output to the control output of uibuilder instead of the data output. The control output is for recognising and acting on new (dis)connections and calls for resending any cache, etc. It will, in the future, also be used for controlling authentication and authorisation.
In your Vue data obviously you must have the msgInput defined so Vue's v-model will have the value stored and synchronized / updated
data() {
return {
msg: "No Message Received from Node-Red",
msgInput: ""
}
},
methods: {
submit() {
console.log("msgInput", this.msgInput);
uibuilder.send({ topic: "myformdata", payload: this.msgInput });
}
},
no need to pass the value in a function like your code since v-model takes care of that and msgInput is readily available to be send using this.msgInput
ps1. when you share code its good to send the complete html, js , flow so we can have a complete picture of your code.
ps2. what db are you using ?
keyup will trigger everytime a user lets go of a key so you would get lots of messages back and would need to handle things until the user had finished typing.
I recommend doing a quick tutorial on keyboard and mouse events in HTML in order to find the event that most suits your user interface. There are lots of different ways to do it. But, as mentioned, a button is the simplest to program.
this is the form and I add an input button. In the js file I add msgInput to data and the function submit() to methods.
var num = msg.payload;
var int = parseInt(num, 10);
console.log(num)
msg.payload=["06/11/20", int];
msg.topic="INSERT INTO test (`Date`,`Value`) VALUES (?,?);"
return msg;
This is the function node to insert into DB and now it works