https://discord.cloudflare.com logo
Join Discord
Powered by
# functions
  • c

    chrisjmccreadie

    12/09/2021, 11:55 AM
    You doing a post request right ?
  • s

    Subh

    12/09/2021, 11:55 AM
    ahh Post
  • s

    Subh

    12/09/2021, 11:55 AM
    Dang it
  • s

    Subh

    12/09/2021, 11:55 AM
    :/
  • s

    Subh

    12/09/2021, 11:55 AM
    So sorry
  • c

    chrisjmccreadie

    12/09/2021, 11:55 AM
    :)
  • c

    chrisjmccreadie

    12/09/2021, 11:55 AM
    Done it myself
  • c

    chrisjmccreadie

    12/09/2021, 11:55 AM
    Many times
  • s

    Subh

    12/09/2021, 11:58 AM
    One more question! Where do I see the request body?
  • g

    geelen

    12/09/2021, 11:58 AM
    you have to
    await request.text()
    i think?
  • g

    geelen

    12/09/2021, 11:58 AM
    something like that
  • c

    chrisjmccreadie

    12/09/2021, 12:00 PM
    Correct
  • s

    Subh

    12/09/2021, 12:00 PM
    Hmm! Just like worker APIs right?
  • s

    Subh

    12/09/2021, 12:00 PM
    hmm, let me try
  • c

    chrisjmccreadie

    12/09/2021, 12:00 PM
    Yes
  • k

    Keenwau

    12/09/2021, 12:18 PM
    Thank you for creating this. It isn't abundantly clear through docs that KV has a local store independent of production store (the one you can edit via dash.cloudflare.com). That confused me until I tried deploying and suddenly, data!
  • k

    Keenwau

    12/09/2021, 12:23 PM
    Unrelated: When I run Next.js
    next dev
    I can't call functions after running
    wrangler pages dev
    proxied to the same port. Same result with
    wrangler pages dev -- next dev
    . Seems like Next assumes anything unmatched under root is a 404, preventing wrangler's dev server from accepting functions. I'm just using a different port, which isn't the end of the world, but was wondering if anyone deploying Next to Pages has encountered this & there's a way to tell Next to ignore my function paths.
  • s

    Subh

    12/09/2021, 12:28 PM
    This part in the document Should be
    export async function onRequestPost({request}) {
    ?
  • c

    chrisjmccreadie

    12/09/2021, 1:01 PM
    No problem it stumped a lot of people including myself
  • m

    markdessain

    12/09/2021, 1:55 PM
    Hey, am I correct in saying that pages functions only supports js for the moment? If so are there plans to support WASM as well?
  • r

    rkusa

    12/09/2021, 5:08 PM
    I've noticed the same and am also wondering who I have to bribe to get WASM support sooner than later?
  • f

    fragje

    12/09/2021, 5:24 PM
    Tried to figure it out, making KV persist locally using miniflare, right? Is it currently supported with pages-functions?
  • h

    HardAtWork

    12/09/2021, 5:36 PM
    Not yet, I don't think, though they are working on it.
  • j

    JustinNoel

    12/09/2021, 8:46 PM
    Anyone have a good example of using strong typing for a PagesFunction? For example,
    Copy code
    export const onRequestGet: PagesFunction = async ({ env, params }) => {
      // Can't find a way to type the params because PagesFunction says it should be a string.
      const id = params?.id;
    
      const aws = new AwsClient({
        // `env` is "unknown" and I can't modify it with any typing on line 1
        accessKeyId: env.B2_ACCESS_KEY_ID,
        secretAccessKey: env.B2_SECRET_ACCESS_KEY,
        region: "...",
        })
    }
  • g

    Greg Brimble | Cloudflare Pages

    12/09/2021, 9:07 PM
    PagesFunction
    takes a three generics: the env, params, and data.
  • j

    JustinNoel

    12/09/2021, 9:21 PM
    Right, but I'm just not understanding how to do that.
  • k

    Keenwau

    12/09/2021, 9:30 PM
    Are you saying you want to give
    {env, params}
    a type or am I missing something else?
  • c

    Cоlе

    12/09/2021, 9:34 PM
    has anyone had any luck getting environment variables to load via wrangler?
  • c

    Cоlе

    12/09/2021, 9:35 PM
    just looking at the
    --help
    I don't even see the
    --env
    option for
    page dev
  • g

    Greg Brimble | Cloudflare Pages

    12/09/2021, 9:44 PM
    Should be
    —binding
1...363738...392Latest