Registry / database / project-rest-client

project-rest-client

JSON →
library1.3.4jsnpmunverified

Project-rest-client is a REST API client library designed for React Native and Laravel backends, version 1.3.4. It provides a structured way to interact with Project DB REST APIs, offering features like offline SQL caching, model abstraction, and query building. The library simplifies API integration with configurable endpoints, live data synchronization, and offline support. Compared to generic HTTP clients, it is opinionated towards Laravel/Project DB conventions and includes built-in caching and model management. Release cadence appears low, with limited community adoption.

npm install project-rest-client
INSTALL
IMPORT
SIG · PROJECT-REST-CLIEN
P
project-rest-client
databasejavascriptv1.3.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ProjectRestClient
import ProjectRestClient from 'project-rest-client'
const ProjectRestClient = require('project-rest-client')
Default export; requires ESM environment (e.g., React Native with Babel). CJS require may work but not guaranteed.
Config
import { Config } from 'project-rest-client'
import Config from 'project-rest-client'
Named export for configuration object; don't use default import.
Model
import { Model } from 'project-rest-client'
import { Model } from 'project-rest-client/models'
Model is exported from the main package, not a subpath. Subpath imports may not be supported.

Initializes the REST client with a config object and performs a GET request to fetch a user by ID.

import ProjectRestClient from 'project-rest-client'; import { Config } from 'project-rest-client'; const config = new Config({ baseURL: 'https://api.example.com', apiKey: process.env.API_KEY ?? '' }); const client = new ProjectRestClient(config); async function getUser(id) { try { const user = await client.get(`/users/${id}`); console.log('User:', user); } catch (error) { console.error('Error fetching user:', error); } } getUser(1);
Debug
Known issues
gotchaThe library is primarily designed for React Native; may not work in Node.js or browser without polyfills.
fix
Use only in React Native projects, or provide necessary polyfills for fetch and async storage.
affects: >=1.0
gotchaConfig object expects a specific structure; missing fields may cause runtime errors.
fix
Always provide baseURL and apiKey. Refer to Config documentation for optional fields.
affects: >=1.0
deprecatedThe query builder API might be deprecated in future versions; prefer using raw endpoints.
fix
Use client.get/post/put/delete directly instead of query builder methods.
affects: >=1.3
gotchaOffline mode requires additional setup with AsyncStorage; not enabled by default.
fix
Enable offline mode by setting offline: true in Config and ensuring AsyncStorage is installed.
affects: >=1.0
breakingThe library expects a Laravel-style API with specific response structures; non-Laravel backends may fail.
fix
Wrap responses or use a generic HTTP client for custom backends.
affects: >=1.0
Errors
Common errors & fixes
TypeError: Cannot read property 'data' of undefined
The library expects a specific JSON structure from the API (e.g., { data: ... }) but received unexpected format.
fix
Ensure your API returns data in the format { data: ... } or configure the response mapping.
Error: Config validation failed: baseURL is required
Config object missing baseURL property.
fix
Provide baseURL in the Config constructor.
Module not found: Can't resolve 'react-native'
The library depends on React Native but is imported in a non-React Native environment.
fix
Only use this package within a React Native project.
Network request failed
API endpoint unreachable due to network issues or incorrect URL.
fix
Check the baseURL and ensure the server is running.
Upgrade
Version history
1.3.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
project-rest-client — npm install project-rest-client · libregistry