@culturehq/client

A JavaScript client that wraps the CultureHQ API.
Getting started
Import the package into your node
application like:
import client from "@culturehq/client";
Every API call function returns a Promise
. You can call them using normal Promise
semantics, as in below:
const getProfile = () => {
client.getProfile().then(response => {
console.log(response);
}).catch(error => {
console.error(error);
});
};
or you can use async
/await
syntax, as in below:
const getProfile = async () => {
try {
const response = await client.getProfile();
console.log(response);
} catch (error) {
console.error(error);
}
};
Each function can be introspected to determine its expected parameters (expectedParams
) and optional parameters (optionalParams
), as in:
const { expectedParams, optionalParams } = client.createEvent;
If a function has multipart
set on its config, it's because one or more of the attributes require a file object. In this case, a File
object should be given for the value, as in:
const avatar = document.querySelector("#avatar").files[0];
const response = await client.updateUser({ userId: 12345, avatar });
Development
First, install the dependencies with yarn
.
Styling
Styling is handled through prettier
. Run it with yarn prettier
.
Testing
Run yarn test
to run the tests with jest
.