Using a Third Party API with Wix fetch

Hi @Yisrael(Wix) ,

I have been trying to achieve this feature for my website and have tried different ways of interacting with the response data based on the resources you provided in your last comment on this post, Yisrael, however, I am not yet able to make the call; every time I run this code, it logs “Fetch did not succeed”, meaning that it didn’t make the call properly. (Attached picture)

I have tried to find a way in which it can properly make the call; as of now, I am just requesting for it to log the data in the console, later I will further manipulate the data, however, I must first make the API call.

import {fetch} from 'wix-fetch';


export function box65_click(event, $w) {

	function formatDate(date) {
		var d = new Date(date),
			month = '' + (d.getMonth() + 1),
			day = '' + d.getDate(),
	

		year = d.getFullYear();

		if (month.length < 2) month = '0' + month;
		if (day.length < 2) day = '0' + day;

		return [year, month, day].join('-');
	}

	//export function makeCall (updated_since, updated_until) {
	var updated_until = formatDate($w("#datePicker6").value);
	var updated_since = formatDate($w("#datePicker5").value);

	const call = {
		url: 'https://api2.vcita.com/v2/appointments' + '?' + 'updated_since' + '=' + updated_since + 'T00:00:00.000+8:00' + '&' + 'updated_until' + '=' + updated_until + 'T00:00:00.000+8:00',
		headers: {
			'Authorization': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
		}
	};
	console.log(call);

	return fetch(call, {
			method: 'get'
		})
		.then((httpResponse) => {
			let unavStaff = httpResponse.staff_id;
			if (httpResponse.ok) {
				return httpResponse.json();
			} else {
				return Promise.reject("Fetch did not succeed");
			}
		})
		.then((json) => {
			console.log(json.staff_id);
		})
		.catch((err) => {
			console.log(err);
		});

I am trying to interact with the following JSON Data (response), specifically with the “staff id” fields, hence the “json.staff_id” and “httpResponse.staff_id”

This is not a response I got through my website, it is a sample response I got from the third party API.

        [{
		"id": "dcd17f240492adff",
		"title": "Half Day Laguna Madre Fishing Trip",
		"client_id": "396ls8lh0yv4ehXX",
		"staff_id": "thfa1bzg4qjmsnXX",
	}, {
		"id": "e1aee88d4921851d",
		"title": "Half Day Laguna Madre Fishing Trip",
		"client_id": "3e3c6lpt76npsrXX",
		"staff_id": "thfa1bzg4qjmoyXX",
	}]

I would very much like to be able to make the API call.

I appreciate anybody’s input on this important matter,

Thanks in Advance,

Nicolas