1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| async function useAjax() { try { const ajax1 = fetch('https://api-node-mongo.onrender.com/api/banners') const ajax2 = fetch('https://api-node-mongo.onrender.com/api/news') const [res1, res2] = await Promise.all([ajax1, ajax2]) const data1 = await res1.json() const data2 = await res2.json() console.log('data1', data1) console.log('data2', data2) const ajax3 = await fetch('https://api-node-mongo.onrender.com/api/products') const data3 = await ajax3.json() console.log('data3', data3) } catch(error) { console.log('錯誤:', err) } } useAjax()
|