So, I set-up a Node.Js server, w/ Express & am using it to write data back to the MSSQL database on the same server, but under it’s own database. I am going to write & read to that database, but this is new territory for me so I’m mostly going from different things I’ve found on the internet.
I’ve got an HTML frame on the page in Dundas, that links to an index.html on the local server & which is where the other scripts to write to the database are. Here’s the script I use to pass data to the server, but you’ll see the username is being pulled from a form & I’m not sure how to pass it from Dundas to the script:
$.getJSON('https://ipapi.co/json/', function(data) {
const CreateUser = document.querySelector('.CreateUser')
CreateUser.addEventListener('submit', (e) => {
e.preventDefault()
const username = CreateUser.querySelector('.username').value;
const termstatus = "1";
const ip = data.ip;
const city = data.city;
const region_code = data.region_code;
const country_name = data.country_name;
const latitude = data.latitude;
const longitude = data.longitude;
post('/createUser', { username, termstatus, ip, city, region_code,
country_name, latitude, longitude })
})
function post (path, data) {
return window.fetch(path, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
}
});
Thx.