Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyanshp authored Mar 20, 2019
1 parent 0400bf7 commit ccc9ffb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ api_request.addEventListener("click", function(e) {
"https://microsoft-azure-microsoft-computer-vision-v1.p.rapidapi.com/analyze?visualfeatures=Categories%2CTags%2CColor%2CFaces%2CDescription";
var ecommerceUrl =
"https://rakuten_webservice-rakuten-marketplace-product-search-v1.p.rapidapi.com/services/api/Product/Search/20170426?keyword=";
var mykey = "<Your-RakutenRapidAPI-key-here>";
var mykey = "14478f483amshce21a80cf4fc7f8p1e1f28jsn1a007f1c3c58";
var imageData = new FormData();
imageData.append("image", byteCharacters);
sendRequest(computerVisionUrl, "POST", imageData, mykey)
.then(function(category) {
console.log("Success! on first request");
console.log(JSON.parse(category.responseText).tags[0].name);
category_result.innerHTML = "Keyword detected - " + JSON.parse(category.responseText).tags[0].name;
category_result.innerHTML =
"Keyword detected - " + JSON.parse(category.responseText).tags[0].name;
return sendRequest(
ecommerceUrl + JSON.parse(category.responseText).tags[0].name,
"GET",
Expand All @@ -86,8 +87,15 @@ api_request.addEventListener("click", function(e) {
})
.then(function(product) {
console.log("Success! on second request");
console.log(JSON.stringify(product));
productUrl_result.innerHTML = "Product on e-Commerce Website - " + JSON.stringify(product);
console.log(
JSON.parse(product.responseText).Products[0].Product.reviewUrlPC
);
productUrl_result.innerHTML =
"<a href='" +
JSON.parse(product.responseText).Products[0].Product.productUrlPC +
"'target='_blank'> <img src='" +
JSON.parse(product.responseText).Products[0].Product.mediumImageUrl +
"'></a>";
})
.catch(function(error) {
console.log("Something went wrong", error);
Expand Down

0 comments on commit ccc9ffb

Please sign in to comment.