-
Notifications
You must be signed in to change notification settings - Fork 137
Extend the fetch function to get headers and status_code #792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
enhancement
New feature or request
Comments
Hello ! Indeed a function like In the meantime, if you need to check if the response is valid json, you can do it using your database's functions. For instance, in SQLite: set x = sqlpage.fetch('http://example.com');
select 'redirect' as component, 'error.sql' as link where not json_valid($x);
select 'text' as component, 'the json is valid' as contents; |
HI, thank you for the hint. |
lovasoa
added a commit
that referenced
this issue
Feb 22, 2025
I started working on it there: https://github.com/sqlpage/SQLPage/pull/827/files |
lovasoa
added a commit
that referenced
this issue
Feb 24, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What are you building with SQLPage ?
I am fetching data with an api call.
What is your problem ? The upstream api may not always be reachable or I get a wrong response.
What are you currently doing ? I try to check the content of the json response. If i get no valid json, I have no idea what to do, to catch the exception.
I would like to extend the fetch function to receive the status_code of a response and to get reponse headers.
Then I can ask for status_code and content-type.
An alternative for me is to use the exec function an build my own try/catch or similar
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: