I’v search my issue about the backend fetch fail in Google.
There was nothing that fit my situation
https://www.wix.com/corvid/forum/community-discussion/backend-fetch-function-not-working-client-says-uncaught-in-promi
However, the answer still not work for me.
Here’s my code in backend.
import { fetch } from 'wix-fetch';
export function myFetch() {
let url = 'my url';
let request = {method:"get"};
return fetch(url, request).then(response => response.json());
}
And call it in page code:
import {myFetch} from 'backend/myBackendFile'
export function button_click(event) {
myFetch().then( (json) => {
return json;
}).catch((error)=>{console.log('error' + error)});
}
The error return a message:
errorNotAuthorizedError: No permission to access the web-method myFetch in module backend/myBackendFile.jsw
PS: I tried to call same url in page with wix-fetch before, it worked. For some security reason, It have to be put in backend fetch.
Please help, thanks a lot.