SyntaxError: Invalid or unexpected token for Javascript code

Status: Open · Asked by Ambrose Chea on · 0 views

teknikal — Question ·

I'm having issues running javascript code. works fine on my local machine, but getting the SyntaxError and I cant debug the issue as the error is too generic. can someone take a look?

Workflow Attached
Code is as follow (without APIKey)

 const apiUrl = "https://api.cliniko.com/v1/appointments?q[]=starts_at:>=2023-08-24T00:00:00z&q[]=starts_at:<2023-08-25T00:00:00z";
const dateToRetrieve = '2023-08-24'; // Replace with the desired date

async function getAppointmentsForDate(date) {

try {
const response = await fetch(apiUrl, {

headers: {
authorization: 'Basic ',
'user-agent': 'Locally',
accept: 'application/json',
'content-type': 'application/json'
}
});

const filteredAppointments = response.json().then(result => result.appointments.filter(appointment => appointment.did_not_arrive));//;
return filteredAppointments;
} catch (error) {
throw new Error(error);
}
}

getAppointmentsForDate(dateToRetrieve)
.then(appointments => {
console.log('Appointments:', appointments);
})
.catch(error => {
console.error('Error:', error);
});

Arshil Ahmad — Reply ·

Hi @teknikal,

Please note that Code by Pabbly requires proficient coding skills. We kindly request you to test your code on a compiler to ensure that it is functioning correctly. For issue related to coding, we suggest seeking the help of a developer (or using ChatGPT). Unfortunately, we cannot assist you with coding-related issues as they are beyond the scope of our expertise.

teknikal — Reply ·

The code works for me, but not when using pabbly as a step. how am I meant to debug this? are you able to provide more info on the error?

Arshil Ahmad — Reply ·

Could you please share a short video showing this code working in a JS compiler? It would help us get a better understanding of the issue.

Back to all forum threads · Log in to reply