Assigning a return value from two chained promises to an outside variable

I have two functions that, through promises, asynchronously return values from HTTP GET requests.

One needs to be called after the other because it depends on the result of the first one.

I trained to chain them using then but, although both GET requests are happening and bringing the expected JSON responses, I can’t figure out how to assign the final return value to a variable that I can use outside both functions.

function getPageInfo(config, lastPageId) {

    axios.get('http://localhost:8000/page/'+lastPageId, config)
         .then(res => {
             return res.data;
         })
         .catch(err => console.log(err));

}

function getUserPages(config) {

    const userId = localStorage.getItem('userId');

    axios.get('http://localhost:8000/user/'+userId, config)
         .then(res => {
             const pageInfo = getPageInfo(config, res.data.pages[res.data.pages.length - 1]);
             console.log(pageInfo);
                return pageInfo;
         })
         .catch(err => console.log(err));

}