Configurable HTTP client with automatic API method generation. More...
| Import Statement: | import Clayground.Network |
ClayHttpClient provides a declarative way to define REST API endpoints and generates callable methods automatically. It supports Bearer token authentication and handles both GET and POST requests.
Example usage:
import Clayground.Network ClayHttpClient { id: apiClient baseUrl: "https://api.example.com" endpoints: { "getUser": "GET users/{userId}", "createPost": "POST posts {postData}" } bearerToken: "your-api-token" onReply: (requestId, code, response) => { console.log("Success:", JSON.parse(response)) } onError: (requestId, code, error) => { console.error("Error:", error) } Component.onCompleted: { api.getUser(123) api.createPost({title: "Hello", content: "World"}) } }
Base URL for all API requests.
Object defining API endpoints. Format: "{HTTP_METHOD} {urlWithParams} [{bodyName}]"
Generated API methods object.
Bearer token for authentication.
Emitted when a request completes successfully.
Emitted when a request fails.