I'm trying to redirect a user to another page, after of complete a process, the process y done by an Api rest, but for making that process, I'm getting information from a form. the problem is that when I try to redirect to the user, it no works, and I'm not sure why.
My JS code is the next:
document.addEventListener('DOMContentLoaded', () => {
console.log('Document is ready');
const $form = document.querySelector('#completedetails');
const $inputName = document.querySelector('#name');
const $inputPassword = document.querySelector('#password');
const $inputCompany = document.querySelector('#company');
const $btn_completedetails = document.querySelector('#btn-completedetails');
const url = "http://localhost:3000/register/";
$form.addEventListener('submit', async (e) => {
e.preventDefault();
let name = $inputName.value;
let password = $inputPassword.value;
let company = $inputCompany.value;
const response = await fetch(`${url}${company}${name}${password}`, { method: 'POST' });
const result = await response.json();
function redirect(to) {
redirect('http://seth.com/dashboard.html?ftime=1');
}
})
})