当前位置:网站首页>node. JS express connect mysql write webapi Foundation

node. JS express connect mysql write webapi Foundation

2022-06-25 20:08:00 Fu Zongheng

newly build

Use webstorm newly build
 Insert picture description here

Cross domain

Be careful app and router, Corresponding module.exports = app; module.exports = router;
stay app.js or index.js Medium plus
 Insert picture description here

Kulian

 Insert picture description here
Port default 3306, In case of modification creatConnection Add port that will do

Interface

var url = require(‘url’);
 Insert picture description here
They correspond to each other : Request method , front end query Parameters , Database execution SQL sentence , Return results
front end data data
var data = req.body
In this case .format For custom methods ,javascript Provides more convenient string templates, such as :

var id = 1
var sql = `SELECT * FROM table1 WHERE id='${
      id}'`
原网站

版权声明
本文为[Fu Zongheng]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202190507135223.html