【发布时间】:2021-10-28 14:50:03
【问题描述】:
有什么方法不使用 setTimeout() 来允许将 fetch 中的数据存储在 stored_data 数组中,然后允许测试函数进行操作。
到目前为止我还没有定义。
let stored_data = []
fetch('https://jsonplaceholder.typicode.com/todos/1')
.then(response => response.json())
.then(json => stored_data.push(json))
function test(e) {
console.log(e)
}
【问题讨论】:
标签: javascript arrays function