Hi everyone,
I hope this post finds you well,
In the current project I’m undertaking, we have to work with an API that gives us data from a software that is used to manage bookings.
We have an account with this software and there is a possibility of accessing our present bookings within the software using their API.
I am having trouble making the API call in the specific format that the software requests it.
My Objective is getting the JSON data as a response to the API Call and hence making some integrations with that specific data in my website, however, to do that I must first make the call correctly.
I am able to supposedly log the call URL correctly in the developer console according to what the external software and what I’ve found at StackOverflow here however, I cannot make the call yet, nor receive any data as a response.
I am not sure if the headers or ‘get’ method is out of place here.
I attach my page code:
*I have replaced my API key with X’s.
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('-');
}
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(response => response.json());
}
I appreciate any help I can get with this important issue.
All comments are gladly welcomed!
Thanks in advance,
Sincerely,
Nicolas