<!DOCTYPE html>
<html lang="en">

<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.0/axios.js"></script>
</head>

<body>
    <script>
        /** axios 并发请求 **/
        function getUserAccount() {
            return axios.get('http://192.9.104.65/data/center-data/publish/b592b412bd384fcfb6a29319e4f29d0f');
        }

        function getUserPermissions() {
            return axios.get('http://192.9.104.65/data/center-data/publish/45760d602d6543598427e720db9f9ad8');
        }

        // axios.all([getUserAccount(), getUserPermissions()])
        //     .then(axios.spread(function (acct, perms) {
        //         console.log(acct, perms);
        //     }));
        async function getData() {
            const data = await axios.all([getUserAccount(), getUserPermissions()])
            console.log('data', data);
        }

        getData();

    </script>
</body>

</html>

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐