Merge into an object from two different API calls
I beleive the issue with

When setting the object at the end with setAllSdksInfo(objCopy) there
was a problem in which it would not set it ok.

Is because Object.assign is not doing what you're expecting it to do, it does not create a deep copy of the source object
TLDR;
When you modify a nested property of the copied object, it will affect the original one, one way of creating a deep copy of the object is JSON.parse(JSON.stringify(obj)) :


const obj_original = {
  a: {
    b: {
      c: 'hello'
    }
  }
}

const obj_copy = Object.assign({}, obj_original);

const deep_copy = JSON.parse(JSON.stringify(obj_original));

obj_original.a.b.c = 'test';

console.log(obj_original); // { a: { b: { c: 'test' } } } 
console.log(obj_copy); // { a: { b: { c: 'test' } } }
console.log(deep_copy); // { a: { b: { c: 'hello' } } }



Keep it DRY :
instead of objCopy[id][&quot;churned_total&quot;] = data[&quot;churned_total&quot;]; you could use destructuring assignment to avoid repeating :
selectedSdksKeys.forEach(async (id, i) =&gt; {
  if (allSdksInfo[id]?.num_installed_apps) return;

  const res = await fetch(`/api/sdk/general_info?sdk_id=${id}`);

  const { num_installed_apps, acquired_total, churned_total } = await res.json();;

  objCopy[id] = {
    ...objCopy[id],
    num_installed_apps, 
    acquired_total, 
    churned_total
  }
});