Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fetch = require('node-fetch');
- const parser = async () => {
- const range = [...Array(35).keys()].map(it => it + 1);
- const promises = range.map(page => {
- return fetch(`https://api.hh.ru/vacancies?page=${ page }`).then(res => res.text())
- });
- const results = await Promise.allSettled(promises);
- const success = results.filter(it => it.status === 'fulfilled').map(it => it.value);
- const errors = results.filter(it => it.status === 'rejected');
- if(errors.length!=0){
- const stack=[];
- stack.push(errors)
- }
- return { success, errors }
- }
Add Comment
Please, Sign In to add comment