var AccessKeyId = 'AKIAJBBUJIPOFZHNFWLQ';
var associateTag = 'somnis-20';
var IdType = 'ASIN';
var itemId = 'B071CV8CG2'
// [YYYY-MM-DDThh:mm:ssZ]
var mytimestamp = '2018-06-01T18%3A38%3A47.000Z';
var mysig = 'TYP2YMFWN4msv0vpQkUz5IchJF%2F8jDwM9%2B4NzdvM%2Bfg%3D';
var xmlurl = 'http://webservices.amazon.com/onca/xml?AWSAccessKeyId=' + AccessKeyId + '&AssociateTag=' + associateTag + '&IdType=' + IdType + '&ItemId=' + itemId + '&Operation=ItemLookup&ResponseGroup=Images%2CItemAttributes%2COffers&Service=AWSECommerceService&Timestamp=' + mytimestamp + '&Signature=' + mysig;
function testdis() {
var myData = {};
// Get input box as string
var inputTextarea = document.getElementsByName("amadeusINPUT")[0].value;
// If no input than use the default
// if (!inputTextarea) {
// inputTextarea = "http://www.amazon.com/dp/B071CV8CG2";
// }
// Clean up Amazon URL entry to extract ASIN as idType
//(https://stackoverflow.com/questions/1764605/scrape-asin-from-amazon-url-using-javascript)
// Regex 1
var regex1 = RegExp("http://www.amazon.com/([\\w-]+/)?(dp|gp/product)/(\\w+/)?(\\w{10})");
m = inputTextarea.match(regex1);
if (m) {
alert("ASIN=" + m[4]);
console.log(m[4]);
var pulledASIN = m[4];
myData.ASIN = pulledASIN;
}
// Regex 2
if (!m) {
m = inputTextarea.match("/([a-zA-Z0-9]{10})(?:[/?]|$)");
myData.ASIN = m;
}
// If there is an ASIN use it as the itemIds
if (myData.ASIN){
itemId = myData.ASIN;
}
//Call to API that return JSON string of product
var thisurl2 = 'https://restaurant-booking-66070.firebaseapp.com/321?ASIN='...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.