Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

I'm getting an error in "Serverless Function" in my SvelteKit Project often

$
0
0

I don't know why I'm getting this error sometimes.

504: GATEWAY_TIMEOUTCode: FUNCTION_INVOCATION_TIMEOUT

I'm using the load function to fetch the posts on the index page.

<script context="module">    export async function load({ page, fetch }) {        const pagination = page.query.get('page') ?? 1;        let PER_PAGE = 2;        // calculate start page        let startPage = +pagination === 1 ? 0 : (+pagination - 1) * PER_PAGE;        // fetch total/count        const totalUrl = `https://myblog.herokuapp.com/posts/count`;        const totalRes = await fetch(totalUrl);        // fecth articles        const url = `https://sveltestrapiblog.herokuapp.com/posts?_sort=created_at:DESC&_start=${startPage}&_limit=${PER_PAGE}`;        const articelRes = await fetch(url);        if (articelRes.ok && totalRes.ok) {            return {                props: {                    posts: await articelRes.json(),                    total: await totalRes.json(),                    pagination: +pagination                }            };        }        return {            status: articelRes.status,            error: new Error(`Could not load ${url}`)        };    }</script>

I don't know what's wrong.


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>