.jsw Backend Web Module Issues

I can’t seem to make backend web modules work.

Trying to link a button on a page to backend .jsw code that calls my API Server. I have written and rewritten my JavaScript and API code many times, but contiunue to get
“Unhandled promise rejection TypeError: (0 , _wixFetch2.default) is not a function” error …

So, I decided either to relearn JS or copy verbatim your SendEmail example from:
https://support.wix.com/en/article/calling-server-side-code-from-the-front-end-with-web-modules

In addition to some caution errors, once wired to the button, it gets the same error message … which by it’s description seems to be one layer below what I am conbtributing to the backend or page code?

Any suggestions?

In the backend code, try to change the first line to

import {fetch} from ‘wix-fetch’

Then, in the 9th line, change wixFetch to fetch.

Note the use of the curly brackets in the first line - this is how to import fetch.

1 Like

Hi,
I’m sorry for your trouble, it seems that there’s a mistake in the article. We’ll take care of it.
Let us know if you need any further help with coding. Thanks!

1 Like

Ah, {fetch] mad a huge difference … thank you for that nudge. Still not working, but now that’s my fault :slight_smile: Love the enhanced tools. And I appreciate the help. Perfection!

1 Like