@nirvanius what function. I've tired global variable can't seem to get it to work right. The script freezes up when it get to the action
Node JS with google trends API
-
Hi,
I want to integrate google trends with my app. I tried it via embedded languages option with node js but for some reason it does not output anything to log.
Can somebody please help me with this?
Here's the API - https://www.npmjs.com/package/google-trends-api -
const mysql = require('mysql2'); // create the connection to database const connection = mysql.createConnection({ host: 'localhost', user: 'root', database: 'db', password: '' }); await(new Promise((resolve, reject) => { /*Place your code here and call resolve to proceed*/ connection.connect(function (err) { if (err) { return console.error('error: ' + err.message); } console.log('Connected to the MySQL server.'); }); resolve() }));Nothing is being shown on logs that is no output whatsoever even for connection of mysql2 module of Node JS. Am I the only person experiencing this?
-
@hippyzipp9 said in Node JS with google trends API:
Nothing is being shown on logs that is no output whatsoever even for connection of mysql2 module of Node JS. Am I the only person experiencing this?
You just don't know javascript
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise -
@hippyzipp9 alternative mysql-cli https://community.bablosoft.com/topic/942/база-данных-mysql/6
But in order to work with the database, you need to know sql. -
const mysql = require('mysql2'); // create the connection to database const connection = mysql.createConnection({ host: 'localhost', user: 'root', database: 'db', password: '' }); await(new Promise((resolve, reject) => { /*Place your code here and call resolve to proceed*/ connection.connect(function (err) { if (err) { reject('error: ' + err.message); } console.log('Connected to the MySQL server.'); resolve() }); })); -
@UserTrue said in Node JS with google trends API:
const mysql = require('mysql2'); // create the connection to database const connection = mysql.createConnection({ host: 'localhost', user: 'root', database: 'db', password: '' }); await(new Promise((resolve, reject) => { /*Place your code here and call resolve to proceed*/ connection.connect(function (err) { if (err) { reject('error: ' + err.message); } console.log('Connected to the MySQL server.'); resolve() }); }));Thanks, your solution worked.