microsoft / typed-rest-client

Node Rest and Http Clients with typings for use with TypeScript
Other
675 stars 118 forks source link

Promise.all problem #219

Closed NeverwinterMoon closed 4 years ago

NeverwinterMoon commented 4 years ago

I am trying to use RestClient as follows:

async function main() {
  const ids = [1, 2, 3, 4, 5, 6, 7]

  return Promise.all(ids.map(fetch))
}

async function fetch(id) {
  try {
   const response = await new RestClient('something').get(`https://some_url/entity/${id}`)
   const result = response.result

   return result
  } catch(e) {
   return {}
  }
}

Requests for some of the IDs return response code 404. Whenever this happens, several other IDs, which would normally return a positive response, also returned as 404. If all of the IDs have a positive response, then it works fine.