SC : Create a custom body object as respone

Hello,

I’m trying to create a server connect that returns an object to be used in my page.
The object will be something like:
{ role: “admin”,
id: 1
}

I get the values from different database actions.

In the Response Action I only can set a Text, should I put the object on the text ?
Should I write it in plain json ? Or Js ? Or is there a way to do it in the wappler sc editor ?

Does the object schema will be available in the app connect side ?

Thanks,

Matthias

1 Like

Looks like a JSON response object?

If so just check output on the query like this and it will be available in the app connect picker
image

Thanks,

My logic is more like,

  • Get a row in table A
    If row’s colX value is 0 -> Get row in table B -> Get colX value
    If row’s colX value is 1 -> Get row in table C -> Get colX value

Then the response object will be:
{
role: Table A value
id: Table B or C value
}

So I was thinking on creating a custom object, maybe I can right all the logic as a sql query but my SQL knowledge is pretty basic

Yes, if you can design a custom query then the response is effectively built for you

You can use set value step for this.
Add this, and set its type to object. Then in the value part, create your json with required keys. In the value part of each key, just use binding from different queries etc.

"role" : "{{query1.role}}"

Something like this should work.

1 Like

Thanks a lot ! It was just in front of my eyes but I missed it :wink: