Wix fetch 'time-out after 14 seconds' error in online site

When using fetch request at the wix developer console i got the response with json data. But when i published my site and send the request from same page, I am getting ExecutionTimeoutError: WebMethod request timed-out after 14 seconds… Did you forget to resolve a promise?

Developer console

while sending request from same page online
console

So you are getting a timeout so to speak before you are getting any data returned.

Have you read about using Wix Fetch and not missed anything out in your code for example.
https://www.wix.com/corvid/reference/wix-fetch.html
https://support.wix.com/en/article/corvid-accessing-third-party-services-with-the-fetch-api

Post the code that you have used up here so that we can look at it to check. Please remove any api keys or personal details before posting any code here.

If I’m not wrong, backend functions are limited to 14 seconds only.

I am getting error in my online site page but the same code working in wix developer review cosole page.

backend code ( backend/serviceModule.jsw )

import {fetch} from 'wix-fetch';  

export function createPolicy() {
const url = 'LINK';
return fetch(url, {
   method: 'post',
   headers: {
       'Content-Type': 'application/json',
       'AppID': 'AppId',
       'Signature': 'Signature',
       'timestamp': '1545391069685'
    },
    body: JSON.stringify({
       "key": "value"
})
      })
 .then(response => {
       return response.text()
 })
 .catch(err => console.log(err));
}

frontend code

import { createPolicy } from 'backend/serviceModule';
 
$w.onReady(function () {
    $w('#button1').onClick(() => {
        createPolicy()
            .then(res=> {
                console.log('success');
                console.log(res)
            })
            .catch((err)=> {
                console.log('error')
                console.log(err)
            })
    })
})

when i tested this on wix developer console i get response with the post data
but after publishing same page when i tried testing online in my google chrome console i get error message.

wix developer console with success message with response data

website console with error message with execution time error

why this is happening when i am testing online while it is working perfectly fine in wix developer.

@vineeta-kande In the live environment the backend functions are limited to 14 seconds of run time.

Which means if the server does not receive a response within that time period it will time out the request.

@shantanukumar847 It taking hardly 3 seconds to receive reponse in wix developer. Then why is it taking longer to respond online web page.

@vineeta-kande Can you try with this:

export async function createPolicy() {
 const url = 'LINK';
 const response = await fetch(url, {
    method: 'post',
    headers: {
 'Content-Type': 'application/json',
 'AppID': 'AppId',
 'Signature': 'Signature',
 'timestamp': '1545391069685'
      },
    body: JSON.stringify({
 "key": "value"
      })
    });
 const alpha = await response.json();
 return alpha;
}

I have same problem. Any fix or workaround please. Thanks in advance.

Please make a new thread and post the code you are using