【发布时间】:2022-01-19 17:26:07
【问题描述】:
我需要执行一个函数作为另一个函数(如链)的结果。 我在下面解释了我的代码的详细信息。
const setter = async () => {
//this my first request that puts data in property value work right and get data.
setPropertyvalue(await (getpropertvalue(slide.slide, 0)));
const lat2 = parseInt(await return_value(propertyvalue, "geolocation_lat"));
//upper two const lat2&long2 depend on setpopertyvalue
const long2 = parseInt(await return_value(propertyvalue, "geolocation_long"));
setTimeout(() => { //and this code is running after all/ I consider time
setGeo({ ...geo, lat: lat2, long: long2 });
}, 2000);
};
setter(); // put this function in onload event
我的问题 = 代码的第二部分不能正常工作,它们只返回 NAN 值 - 我认为它们在第一部分之前运行,但我需要在第一部分之后运行这些代码;
【问题讨论】:
标签: javascript reactjs asynchronous async-await react-hooks