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

    Isaac McFadyen | YYZ01

    03/16/2022, 5:00 PM
    No, I just mean the types.
  • d

    dsincl12

    03/16/2022, 5:00 PM
    crap it removed the interpolation
  • d

    dsincl12

    03/16/2022, 5:00 PM
    ah ok
  • d

    dsincl12

    03/16/2022, 5:01 PM
    then I understand, thank you very much
  • i

    Isaac McFadyen | YYZ01

    03/16/2022, 5:01 PM
    So you're accessing it correctly, just the type needs to be
    string
    .
  • d

    dsincl12

    03/16/2022, 5:01 PM
    but type is bad, got it. super duper thanks man for helping me out
  • i

    Isaac McFadyen | YYZ01

    03/16/2022, 5:01 PM
    No problem 🙂
  • d

    dsincl12

    03/16/2022, 8:43 PM
    @User sorry for pestering you but it seems like it still doesn't work even though I've made the changes above. I now get:
    Copy code
    Cannot read properties of undefined (reading 'fallthrough')
    TypeError: Cannot read properties of undefined (reading 'fallthrough')
    When trying to access platform.env.SENDGRID_API_KEY (I've also tried platform.env['SENDGRID_API_KEY'] but with same error). Got any more tips or suggestions?
  • i

    Isaac McFadyen | YYZ01

    03/16/2022, 8:45 PM
    Hmm... are you returning anything? That doesn't like an issue with the environment variable.
  • i

    Isaac McFadyen | YYZ01

    03/16/2022, 8:45 PM
    Even if you just
    return {status: 200}
    I think that'll work?
  • i

    Isaac McFadyen | YYZ01

    03/16/2022, 8:46 PM
    If you don't return anything it looks for a fallthrough which is where that error comes from.
  • d

    dsincl12

    03/16/2022, 8:48 PM
    hm ok, the changes I've added are a .catch(error) where I'm trying to return an error (since I can't figure out why the API call doesn't work). I'll remove it and see if the error was different
  • i

    Isaac McFadyen | YYZ01

    03/16/2022, 8:49 PM
    I can send you my Sendgrid implementation in SvelteKit if that would help?
  • d

    dsincl12

    03/16/2022, 8:49 PM
    Definitely
  • i

    Isaac McFadyen | YYZ01

    03/16/2022, 8:49 PM
    K, one sec.
  • d

    dsincl12

    03/16/2022, 8:49 PM
    thx!
  • i

    Isaac McFadyen | YYZ01

    03/16/2022, 8:52 PM
    Seems to be over Discord's message limit, so it's attached there.
    sendgrid-implementation
  • i

    Isaac McFadyen | YYZ01

    03/16/2022, 8:53 PM
    I've used text/plain but HTML would work too, it's just that's for an internal contact form so I don't need anything fancy.
  • d

    dsincl12

    03/16/2022, 8:54 PM
    ok at first glance it looks almost identical but I'll go through it line by line, very much appreciated
  • d

    dsincl12

    03/16/2022, 8:54 PM
    thanks once again
  • i

    Isaac McFadyen | YYZ01

    03/16/2022, 9:15 PM
    I'd take a look at the end part, where it checks for the status; if you're not returning for some reason then you'll get that
    fallthrough
    error.
  • d

    dsincl12

    03/16/2022, 9:17 PM
    haha this was funny as always, the problem was that I had missed the name for the sender, now it worked 🙂 anyway this was good learning in the end anyway. Mega kudos for the help man! 🙂
  • i

    Isaac McFadyen | YYZ01

    03/16/2022, 9:17 PM
    Great, glad you got it sorted 👍
  • t

    the-philociraptor

    03/17/2022, 3:42 AM
    Just discovered pages and functions. Looks pretty sweet and would be a great thing to switch to for my project, but still no node support? Do we know if it is on the horizon at all?
  • t

    the-philociraptor

    03/17/2022, 3:42 AM
    I use a number of packages to avoid reinventing the wheel and I'd hate to re-write it all in vanilla js.
  • i

    Isaac McFadyen | YYZ01

    03/17/2022, 12:16 PM
    No, there's no Node.JS support and it's not on the roadmap because that's not how the Workers runtime really works. You can polyfill some stuff but it's dependent on your bundler and what Node packages you're using.
  • t

    the-philociraptor

    03/17/2022, 12:18 PM
    Hmm. I just know that I read workers have some nodejs package support. Figured since functions were basically the same thing that they would get the same.
  • i

    Isaac McFadyen | YYZ01

    03/17/2022, 12:18 PM
    Yeah, they only have some Node.JS package support because those specific packages have chosen to move to Service Worker standards like fetch.
  • i

    Isaac McFadyen | YYZ01

    03/17/2022, 12:19 PM
    For example, stripe and fauna both did that.
  • t

    the-philociraptor

    03/17/2022, 12:19 PM
    Ahh, I see.
1...9899100...392Latest