t3chnoboy / amazon-product-api

:credit_card: Amazon Product Advertising API client
367 stars 104 forks source link

Is this possible to use on the client side? #120

Open arhoy opened 4 years ago

arhoy commented 4 years ago

INside the src folder of a Create React App I have created a file called Amazon with following code.

import amazon from "amazon-product-api";

const client = amazon.createClient({
  awsId: "",
  awsSecret: "",
  awsTag: ""
});

export const amazonItemSearch = async () => {
  const data = await client.itemSearch({
    director: "Quentin Tarantino",
    actor: "Samuel L. Jackson",
    searchIndex: "DVD",
    audienceRating: "R",
    responseGroup: "ItemAttributes,Offers,Images"
  });

  return data;
};

However, I am running into an error saying Access to fetch at 'https://webservices.amazon.com/ 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

How can i use this library to make calls on the client side? I have tried to proxy the URL https://webservices.amazon.com/ without luck

JuanCrg90 commented 4 years ago

You can't use this package in the web app, you can read more about this in the following issues. https://github.com/t3chnoboy/amazon-product-api/issues/66 https://github.com/t3chnoboy/amazon-product-api/issues/86

arhoy commented 4 years ago

I see okay thank you! Is it possible there is a package you can use?

On Sat, Dec 28, 2019, 20:57 Juan Carlos Ruiz González, < notifications@github.com> wrote:

You can't use this package in the web app, you can read more about this in the following issues. #66 https://github.com/t3chnoboy/amazon-product-api/issues/66 #86 https://github.com/t3chnoboy/amazon-product-api/issues/86

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/t3chnoboy/amazon-product-api/issues/120?email_source=notifications&email_token=ACPMK7MZ5PSML76NAHK2OUDQ3ANZDA5CNFSM4KAVRNGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHYXH2Q#issuecomment-569471978, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACPMK7ICWZORNDLXYH5YBBTQ3ANZDANCNFSM4KAVRNGA .

JuanCrg90 commented 4 years ago

I don't think so. The product API requires some delicate API keys that you shouldn't expose in your front end application.