Back-end and Front-end to Insert into MySql database with node.js on remote server from Ionic2

Hello,

I have to ask the previous question, because I’m not get result yet.

How to insert from ionic2 application to MySql database on remote server with node.js. If I have to use code below, what should be a back-end code and front-end to pass inserted value to db.

Thank you

Advice would be helpful

Hello again,

I think your code is nice, but is misses the CORS issue.

Have fun with ionic,

Hello, FrancoisIonic

thanks for feedback

I’m trying to find some useful example on this direction

but as I am newbie, it is not really easy to find, what exactly I have to research, to make it properly and get result

anyway, thanks for hint!

one question, this is due to the getting of a public key during the creation of the project in C:\users\user.ssh\ionic, or in this case it doesn’t matter?

@lado howdy again, when you create a new project, now (it wasn’t the case 6 monthes ago), ionic ask you for a link with ssh key.
This requires you have admin rights on windows, otherwise it will fail, and many other things later.

Hope, it helps,

I do not use Ionic2 for a long time, but I discovered this update with ssh key today, regardless of the question I asked about insertion to the MySql database on remote server with nodejs. So ssh key also should be a added to CORS, or did I misunderstand something? Is there any good example or explanation on CORS?

Hi, @lado

For inserting in my sql try like below code :

app.post('/addpost1',function(req, res){
  console.log(req.body);
  var sql= "INSERT INTO ragisters (fname, lname, email, password, gender, bdate) VALUES ('"+req.body.fname+"', '"+req.body.lname+"','"+req.body.email+"','"+req.body.password+"', '"+req.body.gender+"','"+req.body.bdate+"')"
  console.log(sql)
  db.query(sql, function(err , result) {
     if (err) throw err;
     else
      res.json({msg:"Data inserted sucessfully...!",status: 200, code : 0});
  })
})

thanks