clik
Version:
25 lines (19 loc) • 658 B
JavaScript
import { send } from 'httpie';
export function setup(token, type = 'Bearer') {
const headers = { Authorization: `${type} ${token}` };
return function (method, path, body) {
return send(method, new URL(path, 'https://api.clik.io'), { headers, body }).then(r => r.data);
};
}
export function list(client) {
return client('GET', '/links');
}
export function exists(client, uid) {
return client('HEAD', `/links/${uid}`).then(() => true).catch(() => false);
}
export function update(client, uid, href) {
return client('PUT', `/links/${uid}`, { href });
}
export function create(client, href, uid) {
return client('POST', `/links`, { uid, href });
}