I'm trying to import mssql I have a js file that works fine by it's self but I need to do it so that I can call the function from within a react js environment rather than just node
import React, { Component } from 'react';
import TextInput from '../SmallBits/FormItems/TextInput';
import sql from 'mssql';
//or
var sql = require('mssql');
var dbConfig = {
server: 'localhost',
database: 'TestDB',
user: 'andy',
password: 'andy',
port: 1433
};
export default class LeftBox extends Component {
constructor(props){
super(props);
this.state = {
name: '',
forename: '',
surname: '',
caseID: '',
address: ''
}
this.handleSurnameChange = this.handleSurnameChange.bind(this);
this.handleForenameChange = this.handleForenameChange.bind(this);
this.handleCaseIDChange = this.handleCaseIDChange.bind(this);
this.handleAddressChange = this.handleAddressChange.bind(this);
}
loadEmployees() {
var dbConn = new sql.ConnectionPool(dbConfig);
dbConn.connect().then(function () {
var request = new sql.Request(dbConn);
request.query("select * from EmployeeTable").then(function (recordSet) {
console.log(recordSet);
return recordSet;
dbConn.close();
}).catch(function (err) {
console.log(err);
dbConn.close();
});
}).catch(function (err) {
console.log(err);
});
}
That's all the code that is being called both the import and require statement at the top bot give me the same error that Module not found: Can't resolve 'mssql' in 'C:\Users\wilsona.CHECKMATE\Desktop\reactapp\Workspace\savvy-crm-test\src\components\Parts\Boxes' even though mssql is installed globally should I install locally aswell