Okay so I did not get anything from my last SO question may be I was not so clear in detailing the issue I am facing, so hoping this time I'll get solution for my issue:
var request = require("request");
var options = { method: 'GET',
url: 'https://shop.advanceautoparts.com/web/AAPStoresWithAvailableInventoryCmd',
qs:
{ quantity: '1',
partNumber: '2130015-P',
storeId: '10151',
catalogId: '10051',
langId: '-1',
loadStoresComponent: 'true',
latitude: '',
longitude: '',
prefStoreNickName: '8511' },
headers:
{ accept: 'application/json, text/plain, /',
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36',
'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
origin: 'https://shop.advanceautoparts.com' } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
I am getting accurate data about what I need when I try this at local ENV. BUT when the same code is executed at my EC2 server, I get an awkward response from the code above.
RESPONSE AT LOCAL
{
"loadStoresComponent": ["true"],
"langId": ["-1"],
"quantity": ["1"],
"prefStoreNickName": ["8511"],
"latitude": [""],
"longitude": [""],
"authToken": "-1002%2C3a0VN%2Bt240MbliDjfWLSDJxolLA%3D",
"catalogId": ["10051"],
"DM_PersistentCookieCreated": ["true"],
"partNumber": ["2130015-P"],
"storeId": ["10151"],
"Result": {
"view": "availableStoresList",
"storesListMap": [
{
"inStock": true,
"state": "NC",
"isPrefStore": false,
"distance": 0,
"storeBrand": "AAP",
"city": "MATTHEWS",
"latitude": "35.137527",
"address1": "9507 INDEPENDENCE BLVD.",
"zipCode": "281050000",
"nickName": "8511",
"phone": "704-845-5004",
"longitude": "-80.715079"
},
{
"inStock": true,
"state": "NC",
"isPrefStore": false,
"distance": 4,
.....
.....
}
RESPONSE AT SERVER
<div class="pagewidth">
<div class="logo"> </div>
<div id="tagline"> </div>
<div class="clear"> </div>
<div class="header"> </div>
<div class="content">
<p class="heading">We're offline for a tune-up, we'll be up and running smoothly very soon. </p>
<p class="heading">In the meantime, here are some other options available:</p>
<div class="section group">
<div class="col span_1_of_4"> Visit an <br />
<strong>Advance Auto Parts store</strong><br />
<a href="http://stores.advanceautoparts.com/"><img src="/MaintPage/images/DM150205_maintenance_page_07.png" width="200" height="125" border="0" /></a> </div>
<div class="col span_3_of_4"> Sign up for <br />
<strong>SpeedPerks Rewards</strong><br />
<a href="http://www.speedperks.com"><img src="/MaintPage/images/sp-logo.png" width="204" height="100" border="0" style="margin-top:20px;" /></a> </div>
<div class="col span_4_of_4"> View us on Social Media <strong><br />
Facebook/Twitter/Blog</strong><br />
<a href="https://www.facebook.com/advanceautoparts"><img src="/MaintPage/images/DM150205_maintenance_page_12.png" width="110" height="125" border="0" /></a><a href="https://twitter.com/AdvanceAuto"><img src="/MaintPage/images/DM150205_maintenance_page_16.png" width="92" height="125" border="0" /></a><a href="http://blog.advanceautoparts.com/"><img src="/MaintPage/images/button-m.png" width="90" height="125" border="0" style="margin-left:0px;" /></a> </div>
</div>
<div class="clear"> </div>
<p class="heading">We appreciate your patience – on your next visit, <strong>use coupon code PS20 for 20% off your purchase. </strong></p>
<p class="coupon"><img src="/MaintPage/images/DM150205_maintenance_page_21.png" width="354" height="134" /></p>
<p style="margin:30px; text-align:center;">We look forward to serving you,<br />
The Advance Team</p>
<p style="margin:30px; text-align:center;"> </p>
</div>
</div>
Basically it is an offline page(didn't paste whole HTML body and CSS), by which I feel that they are denying to return the response of my request.
I have tried adding x-forwarded-for
in my call as well but no luck with that.
And I am getting an accurate response by adding x-forwarded-for
in rails, but I guess there may be some extra headers or anything else I need to add in my request to get the desired result.
Any thoughts on my issue?