genkid2020

Untitled

Aug 8th, 2020
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. const https = require('https');
  2. const hhroute = (app) => {
  3. const data = "https://api.hh.ru/vacancies?page=1";
  4.  
  5. // READ
  6. app.get('/', function (request, response) {
  7.  
  8. let req = https.get(data, function(res) {
  9. let data = '',
  10. json_data;
  11.  
  12. res.on('data', function(stream) {
  13. data += stream;
  14. });
  15. res.on('end', function() {
  16. json_data = JSON.parse(data);
  17.  
  18. // will output a Javascript object
  19. console.log(json_data);
  20. });
  21. });
  22.  
  23. req.on('error', function(e) {
  24. console.log(e.message);
  25. });
  26. });
  27. };
  28.  
  29. module.exports = hhroute;
  30.  
Add Comment
Please, Sign In to add comment