[英]I tried to use the .map function but it didn't work on my code
async function getCategoryIds ()
{
let response = axios.get( `${BASE_API_URL}categories?count=100` );
let catIds = response.data.map( c => c.id );
return _.samplesize( catIds, NUM_CATEGORIES )
};
This is my code I tried to change the data in [] but it still don't work这是我的代码,我试图更改 [] 中的数据,但它仍然不起作用
The main issue here is you have not used await in your code.这里的主要问题是您没有在代码中使用 await 。 adding await like the following should solve your problem -
像下面这样添加 await 应该可以解决您的问题 -
let response = await axios.get( `${BASE_API_URL}categories?count=100` );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.