Astro Actions (First Look!)

Поделиться
HTML-код
  • Опубликовано: 9 май 2024
  • Join the early preview for my course! learnastro.dev
    Astro (server) Actions help you write type-safe backend functions you can call from anywhere. Here's a first look at this new experimental feature!
    🔗 Key Links 🔗
    - Github: github.com/coding-in-public/a...
    ---------------------------------------
    🔗 Additional Links 🔗
    - docs.astro.build/en/reference...
    - github.com/withastro/roadmap/...
    ---------------------------------------
    📹 Related Videos 📹
    - Astro DB: ruclips.net/video/yq1uD3pjhM/видео.html
    ---------------------------------------
    🎨 VSCode Theming
    - Font: Cascadia Code: github.com/microsoft/cascadia...
    - Theme: marketplace.visualstudio.com/...
    - Icons: marketplace.visualstudio.com/...
    ---------------------------------------
    🌐 Connect With Me 🌐
    - Website: codinginpublic.dev
    - Blog: chrispennington.blog
    - Twitter: / cpenned
    - Patreon: / coding_in_public
    - Buy Me a Coffee: www.buymeacoffee.com/chrispen...
  • ХоббиХобби

Комментарии • 22

  • @bholmesdev
    @bholmesdev 18 дней назад +12

    Fantastic demo! Glad this simplified your code so much. Made a note that the "failed to validate" throw message could include the error messages for debugging. Also, console ninja is SO COOL

    • @CodinginPublic
      @CodinginPublic  18 дней назад +2

      Thanks for the great tool! I know there's been so much into the crafting of the experience. Excited to see how it continues to develop! And totally agree about console ninja :)

  • @JamesQQuick
    @JamesQQuick 15 дней назад +1

    What a great overview. Thanks so much for this!

    • @CodinginPublic
      @CodinginPublic  14 дней назад

      Thanks so much, James! That’s so kind!

  • @jamesdim
    @jamesdim 18 дней назад +3

    Thanks for covering these new features!

    • @CodinginPublic
      @CodinginPublic  18 дней назад +1

      Yeah, just had a couple of hours to play with it yesterday, but seems really cool!

    • @jamesdim
      @jamesdim 18 дней назад +1

      @@CodinginPublic Definitely! I hope it goes stable soon!

    • @jjaimealeman
      @jjaimealeman 18 дней назад +1

      ​@@jamesdimgiven the speed of the Astro Dev Team - I wouldn't be surprised if it got stable very very soon!!! 😎👍

  • @user-qr1ny5de4r
    @user-qr1ny5de4r 11 дней назад +1

    Thanks for video! But I still have one question: how to use Astro global object in server actions? For example, action for register new user: I want to set cookie (Astro.cookies.set(...)) and redirect user to profile page (Astro.redirect('/profile')), when action adds a new record to DB. How can I do that? 🤔

    • @CodinginPublic
      @CodinginPublic  11 дней назад +1

      If I understand it correctly, it’s just creating a POST endpoint for you. So you should be able to update your db in the function and then set cookies and redirect all from that action file? I can play around with this today if I think about it.

  • @danielgillett370
    @danielgillett370 17 дней назад

    Excellent videos! Keep doing what you're doing. I'm a big fan! I'm on your course as well. It's very good. thank you.
    If you don't mind; Do you think Astro could be used as a production unit to spit out static sites.

  • @WillDelish
    @WillDelish 17 дней назад

    Here is the comment pointing out in the last name error message, ye put “first name” 🤓
    Very cool demo! Astro is growing so fast in features, I can’t keep up.

  • @user-bn5eb9um4x
    @user-bn5eb9um4x 18 дней назад +1

    Wonder if this can return multiple error messages after submit a large form?

  • @404-not-found-service
    @404-not-found-service 10 дней назад

    wwoooww

    • @CodinginPublic
      @CodinginPublic  9 дней назад +1

      Pretty cool, right!?

    • @404-not-found-service
      @404-not-found-service 9 дней назад

      @@CodinginPublic It's great, I'll leave sub and so on, I like Astro and I'm learning it, there is very interesting content on your channel about it so I'll be here more often, I hope to see more new things from Astro, greetings and much success!

  • @user-bn5eb9um4x
    @user-bn5eb9um4x 18 дней назад +1

    Can I don't use Z?

    • @CodinginPublic
      @CodinginPublic  18 дней назад

      I think you need to, but that's also kind of the core experience? So if you don't want to use zod to validate, I'd just use something else?

    • @bholmesdev
      @bholmesdev 18 дней назад +1

      You can! If you omit the “input” option, you get the plan FormData object to do whatever you want. But as Chris mentioned, you won’t get that clean isInputError utility for error messages. It’ll be more to do yourself

    • @user-bn5eb9um4x
      @user-bn5eb9um4x 16 дней назад

      @@bholmesdev Ah, thanks for your work on this. For now, I'm still relying on vanilla JavaScript for all forms.