Interactive API Demo
Try the API
Response
Using JSONPlaceholder REST API (https://jsonplaceholder.typicode.com/)
This example demonstrates a GET request to $HOST/users/{userId}
endpoint.
Code Implementation
JavaScript Example
// Import the API client
import API from '@eseniiaia/core';
const api = new API.Client({
baseURL: 'https://jsonplaceholder.typicode.com'
});
// Fetch a user by ID
document.getElementById('api-form').addEventListener('submit', async (e) => {
e.preventDefault();
const userId = document.getElementById('user-id').value;
try {
const res = await api.get('/users/' + userId);
document.getElementById('api-result').textContent = JSON.stringify(res.data, null, 2);
} catch (err) {
document.getElementById('api-result').textContent = 'Error: ' + err.message;
}
});
How It Works
1. Setup Client
The '@eseniiaia/core' library provides a typed API client with built-in pagination and request caching capabilities.
2. Make Request
The client handles error handling, request serialization, and automatic loading state management.
3. Display Response
The response is automatically formatted in JSON with syntax highlighting and error messages for development clarity.