I have two API urls to call the first one is https://jsonplaceholder.typicode.com/todos I need to get this first url to retrieve the id. After retrieving, call the second url which is https://jsonplaceholder.typicode.com/todos/(id). I am using promise-based for this approach, but my problem is.
How to achieve this in fast retrieving the large number of data?
Note: I am using only Plain JavaScript and CDN for axios.
export const getData = () => {
    const API = `https://jsonplaceholder.typicode.com/todos`;
    return axios.get(API, {
        headers: {
            "accept": "application/json;odata=verbose"
        }
    }).then(res => {
         const data = [];
          const requests = res.map(val => {
            const id = val.id;
            var obj = {};
            const url = `https://jsonplaceholder.typicode.com/todos/(id)`;
            return axios.get(url).then(res => {
                obj['Result'] = res;
            });
        });
            return Promise.all(requests).then(() => {
            return data;
        });
    });
}
This code is working but it was slow getting the data and I need some suggestions for best concepts.
 
    