๐Ÿ“ฆ directus / v6-archive

๐Ÿ“„ javascript-sdk.md ยท 25 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Installation & Usage

Install the package via npm
`npm install directus-sdk-javascript`

Initialize the SDK object with your the desired api key and url

```javascript
const RemoteInstance = require('directus-sdk-javascript/remote');

const client = new RemoteInstance({
  'http://directus.url/api/1.1', // Directus-hosted or own server
  accessToken: 'api-key-12345' // [optional]
});
```

Every endpoint returns a promise which resolves the APIs JSON on success and rejects on an error:

```javascript
client.getItems('projects')
  .then(res => console.log(res))
  .catch(err => console.log(err));
```