Directus SDK for JavaScript (Node and Browser)
Install the package via npm
npm install directus-sdk-javascript
Require the RemoteInstance class (support for local instances coming soon)
const RemoteInstance = require('directus-sdk-javascript/remote');
const client = new RemoteInstance({
url: 'http://instance.directus.io/api/1.1/',
accessToken: [user-token] // optional, can be used without on public routes
});
The client returns a Promise which resolves the APIs JSON data on succes and rejects on error
client.getItems('projects')
.then(res => console.log(res))
.catch(err => console.log(err));
Check the official API docs for a complete overview of all endpoints and available methods