Trying to use AXIOS for get request, error “require is not defined”

My code is below. This is my first time using NodeJS and axios.

I have installed NodeJS on Windows using the downloadable installer. I then installed Axios using npm install axios in powershell as admin.

I’m obviously copy/pasting the boilerplate nodejs code for an axios get request.

I’ve tested the php file using a curl get request from command line (installed actual curl, not the windows shortcut to another program.) So the PHP is accepting get requests and serving json back properly.

The issue I’m stuck on is how to setup axios and node js properly so that my js file runs the get request properly.

This is my code

const loginForm = document.getElementById("login-form");
const loginButton = document.getElementById("login-form-submit");
const loginErrorMsg = document.getElementById("login-error-msg");
const vanillaUrl = "localhost:8081/hospital/php/addapt.php";
const getUrl = "localhost:8081/hospital/php/getpatientappt.php?PatientID=1";

const axios = require('axios')
//get request to get appt for patient id1
axios
    .get(geturl)
    .then(res => {
        console.log(`statusCode: ${res.status}`)
        console.log(res)
        alert(res)
    })
    .catch(error => {
        console.error(error)
    })


loginButton.addEventListener("click", (e) => {
    e.preventDefault();
    const username = loginForm.username.value;
    const password = loginForm.password.value;
    if (username === "user" && password === "1") {
        alert("You logged in!");
        location.reload();
    } else {
        loginErrorMsg.style.opacity = 1;
    }
}
)

These are the errors I’m getting in chrome from the javascript console

Uncaught ReferenceError: require is not defined
    at login-page.js:7:15

DevTools failed to load source map: Could not load content for chrome-extension://hnfanknocfeofbddgcijnmhnfnkdnaad/content.js.map: System error: net::ERR_BLOCKED_BY_CLIENT

DevTools failed to load source map: Could not load content for http://localhost:8081/hospital/login/requestProvider.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

When I run incognito I get

Uncaught ReferenceError: require is not defined
    at login-page.js:7:15

there is no file requestProvider.js.map or content.js.map

This is all being hosted on localhost with xampp. I’m not sure if that affects anything.

I’m not sure what this error is. Got stuck googling it. And I’m not sure how to integrate this code properly.