Skip to content

Browser plugin

Use the generated REST API similarly as if you were on the backend

Section titled “Use the generated REST API similarly as if you were on the backend”

The @uql/core package includes a browser library to easily consume UQL REST APIs from the frontend. It is accessible via the @uql/core/browser sub-path.

  1. Use @uql/core/browser to call a UQL REST API
import { getRepository } from '@uql/core/browser';
import { User } from './shared/models/index.js';
// 'User' is an entity class.
const userRepository = getRepository(User);
const users = await userRepository.findMany(
{
$select: { email: true, profile: ['picture'] },
$where: { email: { $endsWith: '@domain.com' } },
$sort: { createdAt: -1 },
$limit: 100,
}
);