Reading parameters from a get call in Node-red using the .parameter

Hi all.

This is a simple question, but I know I'm asking a lot for somebody to test and recreate the whole thing.
I'm attaching the flow and the sqlite db I'm using.

Basically I recreated a simple user database based on this course, that you can see both on Udemy and Youtube.
I found really mind opening on the scalability and possibilties of node-red, beyond its practical dashboard, more as a site creator.

While I don't expect you to see the all course, I'm stuked on the putton that is deleting a rowid in the database. He has created a get method, and endpoint which is passing in the request a parameter by addin a dot in the url.

/users/delete/.rowid

This parameter is then stored in the message object of the request.

msg.req.params

I'm not receving any parameters.

I'm sharing with you the whole flow, I hope somebody can help or have passed through this problem before me.

[{"id":"c18a164a.177f58","type":"http in","z":"dca62e00.b6298","name":"","url":"/users","method":"get","upload":false,"swaggerDoc":"","x":640,"y":440,"wires":[["98487ce7.8f633"]]},{"id":"ef494c84.42e0c","type":"template","z":"dca62e00.b6298","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<!DOCTYPE html>\n\n<html>\n    <head>\n<link rel=\"stylesheet\" href=\"https://stackpath.bootstrapcdn.com/bootswatch/4.5.2/slate/bootstrap.min.css\" integrity=\"sha384-8iuq0iaMHpnH2vSyvZMSIqQuUnQA7QM+f6srIdlgBrTSEyd//AWNMyEaSF2yPzNQ\" crossorigin=\"anonymous\">\n    </head>\n<body>\n\n\n<div class = \"container\">\n<table class=\"table table-hover\">\n  <thead>\n    <tr>\n      <th scope=\"col\">name</th>\n      <th scope=\"col\">tag</th>\n      <th scope=\"col\">door 1</th>\n      <th scope=\"col\">door 2</th>\n      <th scope=\"col\">door 3</th>\n \n    </tr>\n  </thead>\n  <tbody>\n      {{#payload}}\n    <tr class=\"table-active\">\n      <td>{{name}}</td>\n      <td>{{tag}}</td>\n      <td>{{ACCESS1}}</td>\n      <td>{{ACCESS2}}</td>\n      <td>{{ACCESS3}}</td>\n      <td><a href=\"/users/delete/{{rowid}}\" class=\"btn btn-danger\">Delete</a></td>\n    </tr>\n    {{/payload}}\n  </tbody>\n</table>\n\n<form method=\"POST\" action=\"/users\">\n\n    <legend>Add user</legend>\n    <div class=\"form-group\">\n      <label for=\"name\">name</label>\n      <input class=\"form-control\" id=\"name\" name=\"name\">\n    </div>\n      <div class=\"form-group\">\n      <label for=\"name\">tag</label>\n      <input class=\"form-control\" id=\"tag\" name=\"tag\">\n    </div>\n    <div class=\"form-group\">\n      <label for=\"door1\">Door 1</label>\n      <select class=\"form-control\" id=\"door1\" name=\"door1\">\n        <option>Y</option>\n        <option>N</option>\n      </select>\n    </div>\n        <div class=\"form-group\">\n      <label for=\"door2\">Door 2</label>\n      <select class=\"form-control\" id=\"door2\" name=\"door2\">\n        <option>Y</option>\n        <option>N</option>\n      </select>\n    </div>    <div class=\"form-group\">\n      <label for=\"door3\">Door 3</label>\n      <select class=\"form-control\" id=\"door3\" name=\"door3\">\n        <option>Y</option>\n        <option>N</option>\n      </select>\n    </div>\n    <button type=\"submit\" class=\"btn btn-primary\">Submit</button>\n\n</form>\n\n</div>\n</body>\n</html>","output":"str","x":1000,"y":560,"wires":[["4929055.9f28efc"]]},{"id":"4929055.9f28efc","type":"http response","z":"dca62e00.b6298","name":"","statusCode":"","headers":{},"x":1290,"y":560,"wires":[]},{"id":"98487ce7.8f633","type":"sqlite","z":"dca62e00.b6298","mydb":"4e4abe36.17055","sqlquery":"fixed","sql":"SELECT rowid, * FROM table1","name":"Utenti","x":810,"y":560,"wires":[["3a181b4e.4b5b44","ef494c84.42e0c"]]},{"id":"3a181b4e.4b5b44","type":"debug","z":"dca62e00.b6298","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1130,"y":620,"wires":[]},{"id":"e066ba84.8cb158","type":"inject","z":"dca62e00.b6298","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":640,"y":500,"wires":[["98487ce7.8f633"]]},{"id":"190fdd87.c912b2","type":"comment","z":"dca62e00.b6298","name":"Interacting with Database","info":"Esempio di interazione con un db. I sati possono essere visualizzati e aggiunti all'occrennza attraverso il submit. \n\nE' stato usato [Slate](https://bootswatch.com/slate/)","x":270,"y":460,"wires":[]},{"id":"51169151.adff3","type":"http in","z":"dca62e00.b6298","name":"","url":"/users","method":"post","upload":false,"swaggerDoc":"","x":250,"y":560,"wires":[["98487ce7.8f633","339b92f7.d258de","e73a0b0b.8739b8"]]},{"id":"339b92f7.d258de","type":"debug","z":"dca62e00.b6298","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":430,"y":620,"wires":[]},{"id":"e73a0b0b.8739b8","type":"template","z":"dca62e00.b6298","name":"INSERT","field":"topic","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"INSERT INTO table1 VALUES(\"{{payload.name}}\",\"{{payload.tag}}\",\"{{payload.door1}}\",\"{{payload.door2}}\",\"{{payload.door3}}\" )","output":"str","x":440,"y":560,"wires":[["eaa1947c.162e38","8cc61503.2e52e8"]]},{"id":"eaa1947c.162e38","type":"sqlite","z":"dca62e00.b6298","mydb":"4e4abe36.17055","sqlquery":"msg.topic","sql":"SELECT * FROM table1","name":"INSERT USER","x":620,"y":560,"wires":[["98487ce7.8f633","36344d7c.f49512"]]},{"id":"8cc61503.2e52e8","type":"debug","z":"dca62e00.b6298","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","statusVal":"","statusType":"auto","x":600,"y":620,"wires":[]},{"id":"5fc79ca.dd52864","type":"sqlite","z":"dca62e00.b6298","mydb":"4e4abe36.17055","sqlquery":"msg.topic","sql":"","name":"user database","x":640,"y":120,"wires":[["3bc3eab8.1b3e66"]]},{"id":"1a37ea4e.ea38b6","type":"inject","z":"dca62e00.b6298","name":"insert user 1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"INSERT INTO table1 VALUES(\"Mariette Ulrik\",\"421418319424897128\",\"Y\", \"N\", \"N\")","payload":"","payloadType":"date","x":350,"y":160,"wires":[["5fc79ca.dd52864"]]},{"id":"78ae38b5.283f48","type":"function","z":"dca62e00.b6298","name":"QUERY TAG","func":"msg.topic  = \"SELECT DISTINCT name FROM table1 WHERE tag = \"+ msg.payload\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":350,"y":320,"wires":[["5fc79ca.dd52864"]]},{"id":"926e45be.0a3bc8","type":"inject","z":"dca62e00.b6298","name":"Query for NFC TAG","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"SELECT DISTINCT name FROM table1 WHERE tag =  \"555556319424807026\"","payload":"","payloadType":"date","x":330,"y":280,"wires":[["5fc79ca.dd52864"]]},{"id":"2e855bd7.d56df4","type":"inject","z":"dca62e00.b6298","name":"insert user 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"INSERT INTO table1 VALUES( \"Gaspar Dunne\",\"521416319424807026\",\"N\", \"Y\", \"N\")","payload":"","payloadType":"date","x":350,"y":200,"wires":[["5fc79ca.dd52864"]]},{"id":"ca43c2ed.86c23","type":"inject","z":"dca62e00.b6298","name":"insert user 3","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"INSERT INTO table1 VALUES(\"FAmargo Piel\",\"555556319424807026\",\"N\", \"Y\", \"N\")","payload":"","payloadType":"date","x":350,"y":240,"wires":[["5fc79ca.dd52864"]]},{"id":"8b9e05.4aded1f8","type":"link in","z":"dca62e00.b6298","name":"","links":[],"x":235,"y":320,"wires":[["78ae38b5.283f48"]]},{"id":"e2b3ef6d.d151e","type":"inject","z":"dca62e00.b6298","name":"CREATE TABLE1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"0.1","topic":" CREATE TABLE table1(name TEXT, tag TEXT, ACCESS1 TEXT, ACCESS2 TEXT, ACCESS3 TEXT)","payload":"","payloadType":"date","x":340,"y":120,"wires":[["5fc79ca.dd52864"]]},{"id":"3bc3eab8.1b3e66","type":"debug","z":"dca62e00.b6298","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":850,"y":120,"wires":[]},{"id":"36344d7c.f49512","type":"debug","z":"dca62e00.b6298","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":810,"y":620,"wires":[]},{"id":"1165e79e.252ac8","type":"http in","z":"dca62e00.b6298","name":"","url":"/users/delete/.rowid","method":"get","upload":false,"swaggerDoc":"","x":310,"y":720,"wires":[["1269a867.516258"]]},{"id":"1269a867.516258","type":"debug","z":"dca62e00.b6298","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":530,"y":720,"wires":[]},{"id":"9ff22edb.f793a","type":"comment","z":"dca62e00.b6298","name":"Setup the Database","info":"I'm assuming the db is called users.bd and is located in c/sqlite\n\nYou should inject all this stuff in order to create the table and have the users, or copy past the db in the very same location. ","x":470,"y":40,"wires":[]},{"id":"4e4abe36.17055","type":"sqlitedb","db":"C:\\sqlite3\\user.db","mode":"RWC"}]

the . should be a :
the url would be
http://ip:1880/users/delete/23
e.g.

[{"id":"1165e79e.252ac8","type":"http in","z":"5a245aa1.510164","name":"","url":"/users/delete/:rowid","method":"get","upload":false,"swaggerDoc":"","x":170,"y":2540,"wires":[["1269a867.516258","ae444d7.909f03"]]},{"id":"1269a867.516258","type":"debug","z":"5a245aa1.510164","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":390,"y":2540,"wires":[]},{"id":"ae444d7.909f03","type":"http response","z":"5a245aa1.510164","name":"","statusCode":"","headers":{},"x":400,"y":2600,"wires":[]}]

I would probably take it a step further.
/users/:command/:data
Then you could have urls with command delete or insert.
e.g http://ip:1880/user/insert/data or
/user/delete/data.
Any command and data you wished.

thanks you made my day.
I cannot believe I confused dot with colon :man_facepalming:t4:

thanks!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.