Console for Frontend during Widget Creation

Hi,

I’ve been trying to create a Gov.UK Widget. I can load data into it and run the API from a button getting the result into a variable, but when I return it I can’t work out if anything is going on.

Is there a way to find out if I returned anything or if the javascript is actually doing anything?

I’m returning an array
Array
(
[status] => created
[finished] =>
[created_date] =>
[payment_id] => ***************
[payment_provider] => sandbox
[next_url] => https://www.payments.service.gov.uk/secure/***************
)

and any kind of log I use on this doesn’t give me a result and I then can’t work out where the coding doesn’t function.

this.trigger_action(‘govuk_create’,{text: text},function(container) {
console.log(container);
cs.log(container);
mats.log(container);
var result = container;
console.log(result);
cs.log(result);
mats.log(result);
SELF.response = result;
SELF.status = result.status;
SELF.provider_id = result.provider_id;
SELF.next_url = result.next_url;
SELF.fill_form();
});

I have checked OS API and that doesn’t have any loggin in the frontend either so I can’t see how anything moves in the frontend

Thanks
Robin

Afternoon Robin,

cs.log for backend (main.js) visible in detective, console.log() for frontend, visible in browser console.
You could try cs.log(JSON.parse(variable)) to convert a JSON object to text for logging.

Let me know if the problem persists.

1 Like

Thanks Adam just what I needed