Get the info
const _ = require('lodash');
const fs = require('fs');
const agent = require('superagent');
const readJson = (path, cb) => {
fs.readFile(require.resolve(path), (err, data) => {
if (err)
cb(err)
else
cb(null, JSON.parse(data))
})
}
let harFile = {};
readJson("./localhost.har", (err, data) => {
// console.log(data);
harFile = data;
const entries = _.get(harFile, 'log.entries')
// console.log(entries[0]);
const req = _.get(entries[0], 'request');
// console.log(req);
const method = _.get(req, 'method');
agent(method.toUpperCase(), 'http://localhost:8080/'+_.get(req, 'url'))
.set(_.get(req, 'headers')) // TODO: check if accepts []
.query(_.get(req, 'queryString')) // TODO: check if accepts []
.then(console.log)
.catch(console.log)
// cookies .set('Cookie',
});