Testing End Points
@kapa.ai - what is the best practise for testing custom end points? I understand that the frontend and backend are on different end-points, but is it literally just curl requests or postman?
4 Replies
Hi @Gareth_Simpson. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The best practice for testing custom endpoints in Wasp is to use tools like Postman or curl to send HTTP requests directly to your API endpoints. This approach is straightforward and works well because Wasp's custom APIs are standard HTTP endpoints, so you can interact with them just as you would with any REST API.
For example, after defining a custom API in your Wasp project, you can test it by issuing requests to the appropriate URL and method using Postman, curl, or even your browser (for GET requests). This is explicitly recommended in the Wasp documentation and by community members:
- "You can use Postman to test it as you normally would – nothing special going on there from the client side."
- "You can always use postman and curl, as long as you have the correct payloads."
- "You can call the endpoint by visiting the URL in your browser, or by using a tool like curl or Postman."
Testing backend APIs via Postman
Testing backend in isolation
Migration guide: calling API endpoints There is no special Wasp-specific tool required for this; standard API testing tools are sufficient. Just ensure you use the correct method and path as defined in your Wasp API declaration. If you need to test more complex scenarios or automate tests, you can also use HTTP client libraries in your preferred programming language. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Gareth_Simpson, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
- "You can always use postman and curl, as long as you have the correct payloads."
- "You can call the endpoint by visiting the URL in your browser, or by using a tool like curl or Postman."
Testing backend APIs via Postman
Testing backend in isolation
Migration guide: calling API endpoints There is no special Wasp-specific tool required for this; standard API testing tools are sufficient. Just ensure you use the correct method and path as defined in your Wasp API declaration. If you need to test more complex scenarios or automate tests, you can also use HTTP client libraries in your preferred programming language. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Gareth_Simpson, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
How do I get a user's session id via a curl request? @kapa.ai
Let me check the knowledge base for you again. One moment! :books:
----------------------
I'm sorry, but the knowledge sources do not provide explicit information on how to retrieve a user's session ID via a curl request in Wasp. The documentation explains that Wasp uses sessions for authentication and stores session data in localStorage on the client and in the database on the server, but it does not detail an endpoint or method for obtaining the session ID directly through a curl request. The closest related endpoint mentioned is /auth/me, which returns session info if the user is authenticated, but it does not specify if or how the session ID is included in the response Docs: Auth Overview - Sessions Github Issue: Discuss how we use authentication.
If you need to access session information, you may want to inspect the response from the /auth/me endpoint, but the exact structure and whether the session ID is exposed are not detailed in the available sources.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Gareth_Simpson, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
You can get the user's session ID from the local storage in the browser 😉
was this useful @Gareth_Simpson ?