Skip to content

Commit

Permalink
✨ Added support for v4 API in Content API SDK
Browse files Browse the repository at this point in the history
refs TryGhost/Product#514

- Ghost 4.0 ships with a new set of APIs and v4 is a stable cut from the canary API
  • Loading branch information
naz committed Mar 5, 2021
1 parent e4f06a3 commit 2986ceb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/content-api/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';

const supportedVersions = ['v2', 'v3', 'canary'];
const supportedVersions = ['v2', 'v3', 'v4', 'canary'];
const name = '@tryghost/content-api';

export default function GhostContentAPI({url, host, ghostPath = 'ghost', version, key}) {
Expand Down
37 changes: 37 additions & 0 deletions packages/content-api/test/content-api-test/v4.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Switch these lines once there are useful utils
// const testUtils = require('./utils');

const should = require('should');

const {getInstance} = require('../utils/ghost-server-mock');
const GhostContentApi = require('../../cjs/content-api');

describe('GhostContentApi v4', function () {
let server;
const config = {
version: 'v4',
key: '0123456789abcdef0123456789'
};

before(function (done) {
server = getInstance(config, (serverURL) => {
config.url = serverURL;
done();
});
});

after(function () {
server.close();
});

it('works', function (done) {
const api = new GhostContentApi(config);

server.once('url', ({pathname}) => {
should.equal(pathname, '/ghost/api/v4/content/posts/');
done();
});

api.posts.browse();
});
});

0 comments on commit 2986ceb

Please sign in to comment.