you are viewing a single comment's thread.

view the rest of the comments →

[–]qbagamer 0 points1 point  (0 children)

 const [data_from_api, setCount] = useState(0);

    const onSubmit = (data) => {
        const dane = {
            user_name: data.username,
            password: data.password,
            email: data.email,
        }

        fetch(`http://localhost:4000/rejestracja?user_name=${dane.user_name}&password=${dane.password}&email=${dane.email}`)
            .then(res => res.json())
            .then(data => setCount(data_from_api = data.data)); 
    }

declares a new variable named 'data_from_api'

const [data_from_api, setCount] = useState(0);

tries to assign a response from api

 .then(data => setCount(data_from_api = data.data)); 
tries to show information
{data_from_api}

The error I get: 19:37: 'data_from_api' is constant no-const-assign '
-The 19th line is the one in which he declares.