Let's say i have a signup page that allows a user to create a new participant by inserting the relevant data into an HTML form (ex: firstName, lastName, email, etc). Something like this:
<form id="form" method="POST" action="/myurl">
<label for ="firstName">First Name</label>
<input type = "text" name="firstName">
<label for ="lastName">Last Name</label>
<input type = "text" name="lastName">
<label for ="email">Email</label>
<input type = "text" name="email">
After the user submits the form i want to send the data into a node.js file (let's call it addParticipant.js) that creates a new participant using this data by doing something similar to what's described here: Adding Participants .
From what i understand i can use express and body-parser to handle POST requests in node.js.
My question is, where do i place the "addParticipant.js" file and how do i call it from the form? Should it be in my business network's /lib directory? If so, should /myurl
in the form look like ~/lib/addParticipant?
you can probably have a listener for new signups in a server process and do something like the following REST API post to the REST server, with the participant data POSTed, eg.
return this.httpClient.post('http://myrestserver:3001/api/org.acme.sample.Trader', trader).toPromise();
where Trader
participant captured is something like:
const trader = {
$class: 'org.acme.sample.Trader',
firstName: 'John',
lastName: 'Doe',
email: 't1@acme.net'
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.