JavaScript SDK
The Mojave JavaScript SDK is the easiest way to interact with the Mojave API using Node.js, frontend apps, or serverless environments. It wraps all core endpoints and handles authentication, error handling, and pagination out of the box.
Installation
Install via npm or yarn:
Getting Started
Import and initialize the SDK with your API token:
Basic Usage
Get current user
Create a project
Log time
Last invoices
API Coverage
Resource | Supported Methods |
---|---|
Users |
|
Projects |
|
Tasks |
|
Time Entries |
|
Invoices |
|
Clients |
|
💡 All methods return promises and use async/await.
Error Handling
The SDK throws structured errors:
Pagination
All list methods return paginated results with built-in support:
Use nextPage()
to fetch the next page automatically.
Environment Support
Environment | Supported |
---|---|
Node.js | ✅ |
Browser (SPA) | ✅ (with caution – avoid exposing tokens) |
Serverless | ✅ |
React Native | ✅ |
Best Practices
Always use environment variables to store API tokens
Don’t expose tokens in public browser apps
Catch and log errors from API calls
Use
.env
anddotenv
in local dev