genkid2020

Untitled

Aug 9th, 2020
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. const fetch = require('node-fetch');
  2. const hhroute = (app) => {
  3. // READ
  4. app.get('/', function (req, res) {
  5. fetch('https://api.hh.ru/vacancies?page=1')
  6. .then(res=>res.text())
  7. .then(body=> {
  8. const data = JSON.parse(body);
  9. const output = data.items.map(({id,name,snippet:requirement}) => ({id,name,snippet:requirement}));
  10. res.send(output);
  11. });
  12. });
  13. };
  14.  
  15. module.exports = hhroute;
  16.  
Add Comment
Please, Sign In to add comment