Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const https = require('https');
- const hhroute = (app) => {
- const data = "https://api.hh.ru/vacancies?page=1";
- // READ
- app.get('/', function (request, response) {
- let req = https.get(data, function(res) {
- let data = '',
- json_data;
- res.on('data', function(stream) {
- data += stream;
- });
- res.on('end', function() {
- json_data = JSON.parse(data);
- // will output a Javascript object
- console.log(json_data);
- });
- });
- req.on('error', function(e) {
- console.log(e.message);
- });
- });
- };
- module.exports = hhroute;
Add Comment
Please, Sign In to add comment