CORS response header is not included

Is it the company's responsibility () to rectify one of their endpoints or is it an issue with my code?

I have tested all other endpoints () using the same code below and they all function correctly, except for the specific one in question.

The error message I encountered reads as follows:

Ensure CORS response header values are valid

A cross-origin resource sharing (CORS) request was blocked due to missing or invalid response headers in the request or the associated preflight request.

To resolve this problem, make sure that the response to the CORS request and/or the corresponding preflight request contain the necessary headers with valid values.

Keep in mind that if an opaque response suffices, the request mode can be set to no-cors to fetch the resource without CORS, although this would render the response content inaccessible (opaque).

I have attempted various methods like Node and Live-reload, but the issue persists.

I have studied about CORS and as far as I understand, it is the company's responsibility to include CORS in their response headers.

What are your thoughts on this matter?

const api = apiKey;
const myHeaders = new Headers();

myHeaders.append('x-api-key', api);

const requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow',
  mode: 'cors',
};
const endpoint = 'https://api.documenu.com/v2/menuitems/search/geo?lat=40.688072&lon=-73.997385&distance=1&search=buffalo%20chicken';

fetch(`${endpoint}`, requestOptions)
  .then((res) => res.json())
  .then((data) => console.log(data));

Answer №1

Absolutely correct, it is the responsibility of the company to resolve the issue as they are reluctant to send the CORS header.

After testing the API preview on their platform, it is evident that all endpoints are functional except for the one mentioned.

Update:

I have omitted the documentation link as the domain is no longer active.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Retrieve the Name using the Twitch API

Is there anyone with experience using JQuery or the Twitch API who could assist with this query? I am trying to retrieve a username without the need to click a button or display it in an input box. The following code is from the API examples: $('# ...

A simple method to obtain the ID of the element that has been clicked and save it in a variable to be utilized in a function responsible for

Seeking assistance in optimizing the code below by removing the specific #static id and allowing for dynamic IDs such as #dynamic within the one click function. This would eliminate the need to repeatedly copy and paste the same function with different ID ...

Sending a function return to a React component

What I want to achieve is sending the response from an API call to a React Component and using it to generate a List. My confusion lies in how to pass the value from a function to the component. Do I require state for this process? searchMealsHandler(even ...

How can you display or conceal an HTML page in Jquery Mobile?

This code snippet is used for toggling the visibility of a div. $("[id*=viewMeButton]").click(function(){ $("[id*=viewMe]").toggle(); $("[id*=viewMeButton]").show(); }); In Jquery Mobile, similar functionality can be implemented to show/hide a ...

Passing extra data along with dynamic routes in Reactjs

I'm currently working with Reactjs and Next.js, and I've got my [slug.js] functioning properly with the following URL: <Link href={`/${post.slug}`}><a> However, I need to pass a "hidden" additional parameter along with it. Whenever I ...

Transferring API information into a nested array and displaying the outcome

Currently, I am utilizing an API to fetch an array of users from which I sort them and collect those with a personalTrainerId matching my userId into an array. The ultimate goal is to render these users as cards on the interface. The desired format for th ...

Include a couple of images to the jQuery Slider

I have a website and am looking to incorporate a jQuery slider that meets my needs. However, the current slider only displays 3 pictures. How can I add one or two additional pictures to the slider? Demo: http://d.lanrentuku.com/down/js/jiaodiantu-883/ He ...

Mastering Vue.js: Leveraging v-model within a v-for loop and implementing watchers

After retrieving a list of debits and credits from a server using the fetch function, I store them in my Vue application: const myApp = Vue.createApp({ data(){ return{ debits:[], credits:[], //cut } }, me ...

Notifying individuals of a file's unavailability using HTML tags

I recently created an API that is designed to deliver files to the frontend. Here is how it looks: <a href="downloadFile.aspx?file=token" download target="_blank"> The file download functionality is working fine. However, the issue arises when the ...

The delete button in the "Chip" component of React Material-UI is not functioning as expected

I'm having trouble with the "Chip" control and its "X" button functionality. Unlike the examples shown here: http://www.material-ui.com/#/components/chip Adding the "onRequestDelete" property does include the "X" button, but it doesn't respond t ...

What is the process for adding new data to a data source without overwriting existing information?

I need assistance with a react native app I am developing. I am currently facing an issue where the data received from a fetch request needs to be displayed in a list view. However, each time new data is fetched, it overwrites the previously received data ...

Mouseover feature for image is functioning, but having issues with alignment

I am currently working on displaying images upon mouse over actions. While the functionality is working perfectly, I am facing an issue where the displayed images appear below and the last image takes up space at the bottom. To rectify this problem, I woul ...

Obtaining the Final Document Identifier for Paginating with valueChanges()

When using valueChanges() in AngularFire to subscribe to Firestore data, I encountered an issue where obtaining the last document reference for pagination was not as straightforward as when using onSnapshot. Unfortunately, the approach I was using with o ...

What is the best way to exclude a specific key when adding JSON objects to an array?

I'm facing a challenge with a JSON array of objects that contains other arrays of objects. The structure of this array is not fixed, making it difficult for me to delete specific elements like delete mainArray[0].obj.subobj[1].objToOmit; In my progra ...

transform two series of data into a single object - JavaScript

I'm struggling to merge two arrays into a single array object. Here is the first array, referred to as "keys". Each item in this array should become an object key: ["name", "age", "gender", "status"] The second array contains values and is named "h ...

What is the best way to select the initial element from my class within my component using protractor?

Can anyone help me figure out how to click on the button in this component? I need guidance on navigating through the following path: Is xpath my only option for doing this? I believe a css locator could work as well, but I am unsure of how to construct ...

There is no XHR request sent when invoking the http function

I am facing challenges in configuring a service in angular2 to interact with a REST backend. My attempt at setting up a basic example for sending requests to a rest backend and handling the response seems to be on track. The Service is being called correc ...

Enhance your Vue.js experience with an improved method for monitoring values

My setup involves Vue CLI 3.11 (based on Node.js 12.10) and Google Chrome. I am trying to create a syntax that can bypass the watch function under specific conditions. However, I am struggling because Vue.js handles value changes differently compared to J ...

Rotate Text in HTML <thead> Tag

I need assistance with rotating a table header. https://i.stack.imgur.com/hcvxx.png The HTML th elements within the thead section are described as follows: <th> <span class="rotate-all">Period</span> </th> <th> < ...

JavaScript is failing to update the table values as users interact with it

I've created an HTML table and used PHP to populate the values. The goal is to allow users to update order statuses with a status and message input. Initially it works fine, but after multiple uses, it either updates the wrong row or doesn't up ...