0

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)
})

}
James Z
  • 12,209
  • 10
  • 24
  • 44
  • The bottleneck is clearly on the API call, would you consider to make a batchUpdate API call instead? – Chun Feb 23 '22 at 01:50
  • You need to implement something like background task fire and forget api and then check the status of the api - you will need extra logic for that – Sohan Feb 23 '22 at 06:01
  • I can provide you some rough algorithm where I have done similar thing recently I too had long waiting call which included hitting external API's – Sohan Feb 23 '22 at 06:05

0 Answers0