Skip to content

Commit f0222c4

Browse files
authored
Create README.md
1 parent 0278a69 commit f0222c4

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# custom-type-api
2+
3+
API library to interface with the Custom Types and Slices API for Prismic
4+
5+
## Important
6+
7+
I have intentionally only implemented mainly support for node as I don't see the need to have this ability to interact with the API available client side.
8+
9+
### WIP, please add issues or comments if there is anything that you see :)
10+
11+
The readme is a WIP and the code could probably have some error handling added.
12+
13+
## Example
14+
15+
Below is an example of how to use this to interact with the API for the custom types, it gets a type and writes the result to ta json file.
16+
17+
```js
18+
let Api = require('./dist/index').default;
19+
let credentials = require('./env.json');
20+
let fs = require('fs');
21+
let path = require('path')
22+
let api = new Api('slicemachine-startup', credentials.token)
23+
24+
async function test() {
25+
await api.login()
26+
27+
try {
28+
let response = await api.types().getOne('page');
29+
let res = await response.json();
30+
console.log(res)
31+
fs.writeFileSync(path.join(__dirname, 'page.json'), JSON.stringify(res, null, 2))
32+
} catch (ex) {
33+
console.error(ex)
34+
}
35+
}
36+
37+
test()
38+
```

0 commit comments

Comments
 (0)