Hi Team,
I am encountering an issue while trying to fetch data from Zoho Creator in a custom Outlook add-in. The goal is to retrieve origin and destination information from a specific report, but I'm facing CORS-related errors and failed requests.
Error:

Code Overview:
Here’s the code snippet I'm using to make the API call:
- const fetch = require('node-fetch');
- const apiHeaders = {
- "Authorization": "Zoho-oauthtoken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
- "Cookie": "ZCNEWUIPUBLICPORTAL=true; _zcsr_tmp=ac274c10-0020-4270-9587-795401481110; zalb_442b5845d7=16c37b275de039e0bf53479b8856aa88; zccpn=ac274c10-0020-4270-9587-795401481110"
- };
- async function fetchData() {
- try {
- const response = await fetch("https://www.zohoapis.com/creator/v2.1/data/OWNER_NAME/APP_NAME/report/REPORT_NAME", {
- method: "GET",
- headers: apiHeaders
- });
- if (!response.ok) {
- throw new Error(`HTTP error! status: ${response.status}`);
- }
- const data = await response.json();
- //console.log('API Response:', JSON.stringify(data, null, 2)); // Inspect structure
- // Adjust the extraction logic based on the actual structure of the response
- const origins = [];
- const destinations = []
- // Assuming the structure includes a 'data' key that contains the relevant items
- if (data.data) {
- data.data.forEach(item => {
- if (item.Origin) {
- origins.push(item.Origin);
- }
- if (item.Destination) {
- destinations.push(item.Destination);
- }
- });
- // Remove duplicates and sort the origins
- const uniqueOrigins = [...new Set(origins)];
- const sortedOrigins = uniqueOrigins.sort();
- const uniqueDestinations = [...new Set(destinations)];
- const sortedDestinations = uniqueDestinations.sort();
- console.log(sortedOrigins);
- console.log(sortedDestinations);
- } else {
- console.error('Data structure does not contain expected keys:', data);
- }
- } catch (exception) {
- console.error(exception);
- }
- }
- fetchData();