Skip to content

Conversation

@olivierauverlot
Copy link
Contributor

If you create a RESTful API with SQLPage and the data format transmitted to the client is not HTML, you can use an alias named contents to enhance the readability of your code. This approach is particularly useful for returning data formats such as JSON or XML.

For this use case, using the html property is inconsistent and can be confusing when reading the code.

Copy link
Collaborator

@lovasoa lovasoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, thanks @olivierauverlot . I think we should go further and mention "contents" as the primary name of the property.

Comment on lines 1538 to 1541
### Return data in a format other than HTML
If you create a RESTful API with SQLPage and the data format transmitted to the client is not HTML,
you can use an alias named `contents` to enhance the readability of your code.
This approach is particularly useful for returning data formats such as JSON or XML.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are perfectly right, and I would even go further. I think the docs should mention "html" as being an alias for "contents", not the other way around. "html" is indeed misleading.

We should have a markdown code block here to show a quickly copy-pastable example of both setting the http header and the contents.

We should probably also mention the download component here : https://sql-page.com/component.sql?component=download

@olivierauverlot
Copy link
Contributor Author

I am glad that we share the same opinion on this matter. I have made the modifications in the documentation :)

@lovasoa lovasoa merged commit 17d8925 into sqlpage:main Nov 22, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants