Nuxt.js
1
Вклад в тег
// nuxt.config.js
...
serverMiddleware: [
'~api/api'
],
...
//api.js
import {pool} from "./db";
const express = require('express');
const app = express();
app.get('/valute', function (req, res) {
const sql = "SELECT * FROM `valute-xml`";
pool.query(sql, function (error, results, fields) {
if (error) throw error;
res.json(results);
});
});
//db.js
const mysql = require('mysql2');
const pool = mysql.createPool({
connectionLimit: 100,
host: '',
user: '',
password: '',
database: ''
});
export {pool}