所以,我知道这已经问过,我已经试过像.map
,(function(post){ async })(value)
其他答案,我仍然停留...的Javascript:对象的数组,每个对象改变值异步
所以,我有对象和数组的for循环:
var postsData = [{thumbnail: www.website.com/image.jpg}, {thumbnail: www.website.com/image.jpg}, {thumbnail... etc}];
for (let i = 0; i < 3; i++) {
let thumbnail = postsData[i].thumbnail;
Cloudinary.uploader.upload(thumbnail, function(result){
// not sure what to do here
// result comes back as an object, and I want to change each thumbnail in
// the postsData array to be result.public_id
}, {transformation:[{}]});
} // go through all the items in the array
// do something with "updated" postsData array
一个例子将真正帮助,因为很明显,得到的值更改涉及到一些异步函数。
你'postsData'是无效的 - 也许这是一个起点(值应弦) –