I'm making a react native app and I want to get some data on MySQL database. I made a javascript file doing that but I don't know how to link this class with my react component.
I tried to include it as a module in my component:
var api = require('../../api/APIConnection');
... but I'm having an error:
"Unable to resolve module crypto from 'User/Documents/X/node_modules/mysql/lib/Connection.js
and I can't figure it out.
Here is my javascript module:
module.exports = {
getMySQL()
{
if (this.mysql == null)
return require('mysql');
else
return this.mysql;
},
connect()
{
// Connect to database
con = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
port: 8889,
database: "..."
});
etc...
},
Thank you for help!