Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
directus-sdk-javascript
Advanced tools
Directus SDK for JavaScript (Node and Browser)
Install the package using npm or Yarn:
npm install directus-sdk-javascript --production
or yarn add directus-sdk-javascript
Or download the repo and include /dist/remote.js
into your document:
<script src="/dist/remote.js"></script>
Or use a service that distributes npm packages like unpkg:
<script src="https://unpkg.com/directus-sdk-javascript/dist/remote.js"></script>
Create a new client passing it the options needed to create a connection:
// Only in Node / non-bundled version:
const RemoteInstance = require('directus-sdk-javascript/remote');
// Or (es6+):
import { RemoteInstance } from 'directus-sdk-javascript';
const client = new RemoteInstance({
url: 'http://instance.directus.io/',
version: '1.1', // optional, only need to update if different from default
accessToken: [user-token] // optional, can be used without on public routes
});
The client provides methods for each API endpoint. Every endpoint returns a promise which resolves the APIs JSON on success and rejects on an error:
client.getItems('projects')
.then(res => console.log(res))
.catch(err => console.log(err));
Get and update the current logged in user:
client.getMe()
.then(res => console.log(res))
.catch(err => console.log(err));
client.updateMe({first_name: 'John', last_name: 'Doe'})
.then(res => console.log(res))
.catch(err => console.log(err));
Custom api endpoints, implemented on the server under customs/endpoints
, are also available. Here is an example for calling the http://instance.directus.io/api/example
endpoint:
client.getApi('example')
.then(res => console.log(res))
.catch(err => console.log(err));
client.postApi('example', {custom_var: 'value'})
.then(res => console.log(res))
.catch(err => console.log(err));
Since the SDK uses promises, you can also use it with async/await:
const projects = await client.getItems('projects');
Check the official API docs for a complete overview of all endpoints and available methods
FAQs
Directus SDK for JavaScript (Node and Browser)
The npm package directus-sdk-javascript receives a total of 25 weekly downloads. As such, directus-sdk-javascript popularity was classified as not popular.
We found that directus-sdk-javascript demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.