0

I wrote simple JavaScript that should make a request to my server. I opened one more chrome window with turned off security. So I don't have an error connected with CORS.

Here is this JS code:

const registerBtn = document.querySelector('.register-send');

registerBtn.addEventListener('click', function (e) {
    const req = new XMLHttpRequest();

    req.onload = function () {
        console.log('Success');
    }

    req.open("POST", 'localhost:3000/api/register?name=Roma&username=Roma123&password=120&profileDescription=5&human=man');

    req.send();
});

I turned on my server. But, unfortunately, I have an error.

loginOrRegister.js:47          POST localhost:3000/api/register?name=Roma&username=Roma123&password=120&profileDescription=5&human=man net::ERR_UNKNOWN_URL_SCHEME

Please, help!

  • 1
    You forgot the `https://` or `http://` at the start. Read the Wikipedia article about how a [URL](//en.wikipedia.org/wiki/URL#Syntax) looks like. The error message says _unknown URL scheme_. Is `localhost:` your scheme? No, it’s not. It’s the hostname. – Sebastian Simon Jan 15 '23 at 14:20

0 Answers0