# Debugging backend

**URL:** <https://forum.wixstudio.com/t/debugging-backend/34264>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [May 10, 2018, 1:44pm UTC](https://forum.wixstudio.com/t/debugging-backend/34264 "2018-05-10T13:44:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rebel](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@rebel](https://forum.wixstudio.com/u/rebel)\
**Post date:** [May 10, 2018, 1:44pm UTC](https://forum.wixstudio.com/t/debugging-backend/34264/1 "2018-05-10T13:44:38Z")

</div>

So, I have read “Testing and Debugging Code with Wix Code” but reality doesn’t seem to work that way!

I have written a function in http-functions.js to handle a webhook from an external site. When I test it in preview mode, I can see from the external site that the http request is being received and a response sent back. I can vary that response by returning ok, created, notFound, etc. from the code so I know that there is nothing fundamentally wrong with the setup.

Now I need to debug in order to view the payload of the webhook, which is a Json object, and check that I am unpacking it correctly. But I never see any output from my console.log calls in the browser developer console or the wix console in preview. Putting console.log calls in the code for the home page gives exactly what I would expect, but not in http-functions.js. The wix console tells me to “open masterPage.js in Developer Tools” in order to debug. When I do that all I see is an empty onReady function, not the code I have written and want to step through.

There is another issue, that attempting to write to a database collection from within http-functions.js always fails so I’m not even able to use a log file as a fallback. In any case, writing to the database is a fundamental part of handling the webhook, so I need to get that working as well. Again, my database access code works fine when it is in the home page, so this isn’t just a coding error. And the examples in “Exposing a Site API with HTTP Functions” use effectively the same code structure as I have got, to save data records.

So what is going on?

---

<div class="post-metadata">

**Author:** ![admin-23](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/admin-23/32/708_2.png) [@admin-23](https://forum.wixstudio.com/u/admin-23)\
**Post date:** [May 13, 2018, 1:16pm UTC](https://forum.wixstudio.com/t/debugging-backend/34264/2 "2018-05-13T13:16:01Z")

</div>

Hi,

calling console logs in http-functions is useless since the code is always executed on the server side.  
This is unlike backend functions that are called from the front end.

To help with debugging you can create a collection that stores the JSON request/response

If the insert function fails to insert check the collection permissions

> **[CMS: Collection Permissions Overview | Help Center | Wix.com](https://support.wix.com/en/article/cms-collection-permissions-overview)**
>
> Before you begin:You may want to read about your collection fields before reading this article. For a more specific guide, you can read changing your collection

---

<div class="post-metadata">

**Author:** ![shay-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/shay-wix/32/669_2.png) [@shay-wix](https://forum.wixstudio.com/u/shay-wix)\
**Post date:** [May 15, 2018, 11:05am UTC](https://forum.wixstudio.com/t/debugging-backend/34264/3 "2018-05-15T11:05:37Z")

</div>

Hi,

We are in the final stage of providing you all the ability to better view all backend logs. We will update you soon.

---

<div class="post-metadata">

**Author:** ![rebel](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@rebel](https://forum.wixstudio.com/u/rebel)\
**Post date:** [May 15, 2018, 5:17pm UTC](https://forum.wixstudio.com/t/debugging-backend/34264/4 "2018-05-15T17:17:19Z")

</div>

Thanks for that. I managed to get wixData working (stupid typo in my JS code, duh!) so have been debugging to a log file and made progress that way. I understand that server side logging to the client isn’t straightforward and was a bit surprised when the documentation seemed to suggest that it was happening.

---

<div class="post-metadata">

**Author:** ![johnsonsflorists](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/johnsonsflorists/32/11026_2.png) [@johnsonsflorists](https://forum.wixstudio.com/u/johnsonsflorists)\
**Post date:** [May 2, 2019, 12:41am UTC](https://forum.wixstudio.com/t/debugging-backend/34264/5 "2019-05-02T00:41:15Z")

</div>

Is there backend logs to view now?

---

<div class="post-metadata">

**Author:** ![embsats](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/embsats/32/10580_2.png) [@embsats](https://forum.wixstudio.com/u/embsats)\
**Post date:** [July 28, 2019, 6:22pm UTC](https://forum.wixstudio.com/t/debugging-backend/34264/6 "2019-07-28T18:22:27Z")

</div>

bump  
Also interested. Thanks

---

<div class="post-metadata">

**Author:** ![admin-23](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/admin-23/32/708_2.png) [@admin-23](https://forum.wixstudio.com/u/admin-23)\
**Post date:** [July 29, 2019, 1:59pm UTC](https://forum.wixstudio.com/t/debugging-backend/34264/7 "2019-07-29T13:59:25Z")

</div>

Check out these articles and video to learn how to use the **Site Monitoring** tool

[Corvid: About Site Monitoring](https://support.wix.com/en/article/corvid-about-site-monitoring)  
[Corvid: Viewing Live Site Events](https://support.wix.com/en/article/corvid-viewing-live-site-events)  
[Corvid: Connecting Site Events to a Monitoring Tool](https://support.wix.com/en/article/corvid-connecting-site-events-to-a-monitoring-tool)  
[Corvid: Generating a Site Monitoring Event to Debug Your Site](https://support.wix.com/en/article/corvid-generating-a-site-monitoring-event-to-debug-your-site)

[Corvid by Wix | How to Use the Site Monitoring Tool to Track Events and Errors](https://www.youtube.com/watch?v=N9DP020ae1w&feature=youtu.be) @ Youtube
