genkid2020

Untitled

Aug 9th, 2020
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. const fetch = require('node-fetch');
  2. const parser = async () => {
  3. const range = [...Array(35).keys()].map(it => it + 1);
  4. const promises = range.map(page => {
  5. return fetch(`https://api.hh.ru/vacancies?page=${ page }`).then(res => res.text())
  6. });
  7.  
  8. const results = await Promise.allSettled(promises);
  9. const success = results.filter(it => it.status === 'fulfilled').map(it => it.value);
  10. const errors = results.filter(it => it.status === 'rejected');
  11. if(errors.length!=0){
  12. const stack=[];
  13. stack.push(errors)
  14. }
  15. return { success, errors }
  16. }
  17.  
Add Comment
Please, Sign In to add comment