How does redux ensure that state changes before requesting new data?

The

list is an interface, and then get the specific details according to the id of the list, and then splice the information of the list in redux state. However, if the then after the list request calls the API of details, there is no guarantee that the state of the list has been obtained. What should I do with this? Redux-thunk

used
Mar.13,2021

redux practice async is not friendly. Try using redux-thunk or redux-saga


as I understand it, do you want to request two interfaces and then splice the data returned by the two interfaces into state ?

if so, it basically has nothing to do with redux . You can encapsulate the Promise implemented by the interface, merging the two requests into one, and writing something like this:

const fetch = require('isomorphic-fetch');
const doubanApi = 'https://api.douban.com/';

// v2/movie/top250
// v2/movie/subject/:id

//  Top250 No.1 
fetch(`${doubanApi}v2/movie/top250`)
    .then(r => r.json())
    .then((data) => {
        const firstId = data.subjects[0].id;
        return fetch(`${doubanApi}v2/movie/subject/${firstId}`);
    })
    .then(r => r.json())
    .then((data) => { console.log(data); })
    .catch((e) => { console.log(e); });
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2c349-e045.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2c349-e045.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?