Answer the question
In order to leave comments, you need to log in
What causes Net.createConnection is not a function?
Hello, I recently started using NodeJS instead of PHP. And I started with AngularCLi (since AngularJS and MaterialAngularjs were used before), at the moment when I need to display data from the database, I get the error
"Uncaught TypeError: Net.createConnection is not a function"
var mysql = require('mysql');
//так же пробовал import * as mysql from 'mysql';
var connection = mysql.createConnection({
host : 'хост',
database : 'база',
user : 'пользователь',
password : 'пароль'
});
connection.connect();
connection.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
if (err) throw err;
console.log('The solution is: ', rows[0].solution);
let Error = false;
});
connection.end();
declare var require: any;
declare var System: any;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question