Hello guys i'm Nicholas a software developer from Nigeria, who's new to react. I am trying to create and admin signup page for a react app with django as backend. when i make a POST request i get these errors
. CORS has been enabled, when i test the api endpoints using Postman, it works but when i make the api call from my code it doesnt. here is the code snippet
import React, { useState } from 'react';
import axios from 'axios';
const AdminSignup = () => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [firstName, setFirstName] = useState('');
const [lastName, setLastName] = useState('');
const [phoneNumber, setPhoneNumber] = useState('');
const handleSubmit = async (event) => {
event.preventDefault();
try {
const response = await axios.post('http://127.0.0.1:8000/admins', {
email,
password,
firstName,
lastName,
phoneNumber,
});
// Handle successful signup here
console.log('Sign-up successful!', response.data);
} catch (error) {
console.error('There was an error!', error);
}
};
Top comments (0)