`Multiple fetch requests?
S
S
sirhiiOlegovich2021-02-03 16:12:07
React
sirhiiOlegovich, 2021-02-03 16:12:07

Multiple fetch requests?

there is action

@action
    getLogList = async (range, type) => {
        this.isLoading = true;
        try {
            const result = await Http.get(`${serverApi}/log-list?range=${range}&type=${type}`);
            console.log(result, 'result');
            this.chartsData[type] = result.data;
            this.isLoading = false;
            this.isError = false;
            this.errorMsg = null;
        } catch (e) {
            this.chartsData[type] = null;
            this.isLoading = false;
            this.isError = true;
            this.errorMsg = e;
        }
    };

In the component, you need to call 3 actions with different data, and place them in the state
useEffect(() => {
        getLogList('1', 'markeCap'),
        getLogList('1', 'newTotalSupply'),
        getLogList('1', 'marketCap'),
    }, [getLogList]);

How to do it right?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Shvedov, 2021-02-03
@mmmaaak

avete Promise.ol([...])

F
Fixid, 2017-08-05
@Homise

https://magora-systems.ru/etapy-razabotki-prilojeniy/
https://spark.ru/startup/componentix/blog/4499/osn...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question