This page shows JSON inside plain empty html/body tags. For example:
<html>
<body>
**JSON DATA ***
</body>
</html>
I can access that page fine doing it normally within a browser. But, when I send a request it says that my credentials are invalid (The response error is pretty much in the title). And here is the code
import dotenv = require('dotenv');
dotenv.config({ path: '../logins.env' });
import rp = require('request-promise');
const jsonUrl = `http://availability.emodal.com/ImportAvailability/GetContainerInfoList?sgrdModel=%7B%22searchtext%22:%22%22,%22page%22:1,%22pageSize%22:280,%22sortBy%22:%221%22,%22sortDirection%22:%22asc%22,%22sortColumns%22:%22%22%7D`;
const authOpts = {
uri: jsonUrl,
auth: {
user: process.env.EMODAL_id,
pass: process.env.EMODAL_pw,
sendImmediately: false
},
method: 'get'
}
rp(authOpts)
.then(resp => {
console.log(resp);
}).catch(err => { throw Error(err)});
I tried changing everything around. Like adding headers, or putting json: true, or changing sendImmediately to true. Nothing works. What am I not understanding or what am I doing wrong?
Here is an image showing the error in terminal:
Thank you