DEV Community

Gutopro
Gutopro

Posted on

1

Recieving 404 page not found and 400 bad request

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
Image description. 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);
    }
};
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay