I have an api request on the backend that looks like this:
import Acuity from 'acuityscheduling';
let acuity = Acuity.basic({
userId: xxx,
apiKey: 'xxx'
});
export function reschedule(id, datetime){
var options = {
method: 'PUT',
body: {
datetime : datetime
}
}
acuity.request('appointments/' + id + '/reschedule', options, function (err, res, appointments) {
if (err) return err;
return appointments;
})
}
I want to return err or appointments to the front end but keep getting undefined.
I've tried
return acuity.request...
but that only returns the actual request itself to the front end and not the response which is what I need
My front end code looks like:
import {reschedule} from 'backend/aModule'
reschedule(data._id, datetime).then((msg) => {
console.log(msg) //returns undefined
})
Can anyone help me out with this?
Try return acuity.request('appointments/' + id + ' /reschedule', options, function (err, res, appointments) { if (err) return err; return appointments; })
The 'return err' or 'return appointments' returns from the callback 'function' to the 'reschedule function'. So you need a return from reschedule to caller.
did you ever get an answer? i just ran into this issue and cant find it anywhere.
Thank you.