1

I've been trying to request information from the Shoppy API, and the response I'm getting on chrome and opera is this

this

In the Shoppy API documentation it says that it's required to set a user-agent which is impossible to my understanding from looking at stack overflow posts. However, the question I am wondering about is if there is a workaround?

sidenote: with firefox i successfully get a response from the API with a CORS extension enabled.

shoppy api documentation

mounted () {
 axios
  .get('https://shoppy.gg/api/v1/products/', {
    headers: {
      'Authorization': 'placeholder',
      'Access-Control-Allow-Origin': 'https://shoppy.gg',
      useCredentails: true, 'user-agent': 'Shoppy'}})
  .then(res => console.log(res))
  .catch(err => console.log(err));
  // .then(response => (this.info = response))

}
Phil
  • 157,677
  • 23
  • 242
  • 245
Zekima
  • 13
  • 3
  • Your browser automatically sets the `User-agent` request header. Also, `useCredentials` should not be in your `headers` object and `Access-Control-Allow-Origin` is not a **request** header, it can only come from the server in a **response** – Phil Apr 29 '20 at 00:13
  • As for your CORS issues, there's hundreds of duplicates on StackOverflow. I'll try and find a nice one. – Phil Apr 29 '20 at 00:15
  • 1
    Thank you Phil my CORS and user-agent problem is no more – Zekima Apr 29 '20 at 00:31

1 Answers1

2

You only have to worry about setting a user-agent if you're using their API from a non-browser client app. If you're using their API on a Web site via a browser, then the browser's user-agent will automatically be used, without you having to do anything.