node js api design and waiting for long process excution

59 Views Asked by At

I have 2 tables

  1. pin codes - list of pin codes [lets take 5000]

  2. addresses - corresponding addresses-from an API

I want to write an API like '/update-addresses' by using Node Js

After updating the required table API should give response back like 'update done'

above scenario was working fine in my case when i am going with 10 pin codes.

but for 100 or more it's taking too much time to complete. is it will through an error like timed out?

how we can reduce the time for 100 or more pin codes?

algorithm:

fun(res,req){
a=list of pin codes 
output=[]
Promise.all(a.map(){
 let p=new Promise((resolve)=>{
   axios(API call).then(d=>{
     resolve(d)
   })
 })
 return p.then(out=>{
   output.push(out)
 })
}).then(()=>{
  res.send(output)
})

}
0

There are 0 best solutions below