J
J
JordanBelford2021-01-21 12:04:22
React
JordanBelford, 2021-01-21 12:04:22

Why are parameters not passed to the function?

Good afternoon! For some reason, the received response from the server is not passed to the function. Who knows what the problem is?

const requstURL = 'http://localhost:5000/main';

    const sendRequst = (method, url) => {
        return fetch(url).then(res => {
            return res.json()
        })
    }

    sendRequst("GET", requstURL).then(data => {
        props.test(data.text)
        console.log(data)
    });

Response from server:
600943c500cdf169205073.png
6009438de36e8153050869.png
60094745932b0797079332.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Pastukhov, 2021-01-21
@JordanBelford

So you have on the screen where data is an array, and you do - and test does not exist, so undefined is set inthen(data => props.test(data.test)props.mainPage.messages

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question