genkid2020

Untitled

Aug 9th, 2020
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. const fetch = require('node-fetch');
  2. async function parser() {
  3. const stack = [];
  4. // READ
  5. try {
  6. for (page = 1; page <= 35; page++) {
  7. await Promise.all(fetch(`https://api.hh.ru/vacancies?page=${page}`))
  8. .then(res => res.text())
  9. .then(body => {
  10. const data = JSON.parse(body);
  11. const output = data.items.map(({id, name, snippet}) => ({
  12. id,
  13. name,
  14. snippet
  15. }));
  16. console.log(output);
  17. });
  18. }
  19. } catch (err) {
  20. console.log(err);
  21. stack.push(err);
  22. }
  23. }
  24.  
  25. module.exports = parser;
Add Comment
Please, Sign In to add comment