异步编程
2025年2月7日小于 1 分钟
The async function
declaration creates a binding of a new async function to a given name. The await
keyword is permitted within the function body, enabling asynchronous, promise-based behavior to be written in a cleaner style and avoiding the need to explicitly configure promise chains.
reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
//usage:
async function fetchMapData() {
const res = await fetch('https://geo.datav.aliyun.com/areas_v3/bound/100000_full.json')
return await res.json()
}