Customer Login with Authenticate
Welcome to our Multivendor Ecommerce Website built with Django, ReactJs, and REST API. In order to access the website, customers need to log in with their credentials.
// Make API call to authenticate customer login
fetch(‘https://api.example.com/login’, {
method: ‘POST’,
body: JSON.stringify({ username: ‘customer123’, password: ‘password123’ }),
headers: {
‘Content-Type’: ‘application/json’
}
})
.then(response => response.json())
.then(data => {
// Handle login response
if(data.success) {
alert(‘Login successful! Redirecting to homepage…’);
window.location.href = ‘/homepage’;
} else {
alert(‘Login failed. Please try again.’);
}
})
.catch(error => {
console.error(‘Error:’, error);
});
My life depends on these
You are amazing, thank you alot