🎉 BetterResponse v2

Sometimes you need something faster than the amazing Wappler devs can arrange. So to answer my own topic (How to send a response with custom header) I created a module that allows me to set headers in a response created by a server action.

To quote @JonL: Drop these two babies in /extensions/server_connect/modules

Features:

  • Set headers in your response
  • Default status of a response is 200

##Example use case: setting a [Content-Type in your response] ##(Server Connect Response Action -> Set Content-Type in response headers) and a couple of other headers:

1.Add the action in a server action:

  1. Add headers, for example:

  2. The server now responds with the set headers:

It’s my first module - tips/contributions are welcome

Updates

2022.01.08 | V2: Simplified code, fixed dmx {{variable}} not parsing and showing as plaintext

14 Likes

Hey buddy!

Congrats on your first release! Nice to see new releases in this category!

Thanks Jon! Appreciate it!

It was definitely not on my to-do list to make this yesterday, but I’m glad to better understand how this works.

It’s opening my eyes to how any server connect can be relatively easily expanded like this.

I could simply copy the code from the Wappler devs out of core.js - but I couldn’t find their .hjson equivalent. After making the .hjson with their code, it simply worked just like the original component. Easy to take it from there…

Very excited for custom components, then I think I can do everything I want with Wappler.

PS Any tips on how to debug these things efficiently? I’ve been putting some extra comments into the request like: .send(data + 'the headers are not set') but I’d rather do the equivalent to console.log… also I don’t think this will work well if I’m not actually working with a ‘response’ addon.

Sorry for the late reply. I missed your PS.

The really efficient way to debug these is using chrome devtools for nodejs.

But sometimes this can be overkill and some well placed console.log() are more than enough.