New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

kitsu

Package Overview
Dependencies
Maintainers
1
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kitsu - npm Package Compare versions

Comparing version 5.0.0-beta.1 to 5.0.0

lib/index.js

184

CHANGELOG.md

@@ -0,1 +1,185 @@

## 5.0.0 (2018-02-16)
##### Breaking Changes
* **kitsu:** remove deprecated isAuth() function (42b9d08e)
##### Build System / Dependencies
* hide lerna info output (604a5c6c)
* publish workspace packages, not root (108d64e3)
* re-add changelog generation (d00932e0)
* re-add build documentation command (c8ff23cf)
* remove bail argument for build command (9d0576d3)
* re-add build script to test command (d9a45d6c)
* **kitsu:** fix commonjs exported name for kitsu-core (6c0a3281)
##### Chores
* **kitsu-core:**
* add npmignore (108fc957)
* rename prop to key in serialise (64b44d26)
* **kitsu:**
* removed unused files from npmignore (ec382e25)
* update examples (8a826cbc)
* **deps:**
* update eslint-config-wopian to ~1.3.0 (7655109d)
* update lock file (356b1d88)
* update rollup to ~0.56.0 (bd6c286c)
* update lerna to ~2.9.0 (4f43c665)
* update rollup to ~0.56.0 (#127) (950363d6)
* revert changes to kitsu-core dependency (227a313f)
* pin new devDeps to minor instead of major (979cd879)
* update jest to ~22.3.0 (#124) (34410887)
* update eslint-config-wopian to ~1.2.0 (#123) (5702e214)
* split kitsu into a monorepo (#126) (b825acc8)
* re-add major and minor publish scripts (4afdf246)
* **lerna:** remove publish skips (59d66518)
##### Continuous Integration
* **travis:** re-enable email notifications (7596a8d7)
* **codeclimate:**
* disable eslint until custom configs are supported by codeclimate (f350da04)
* exclude example and cases directory (b7c26871)
* fix spec exclusion pattern (656f46f9)
* update exclude patterns (3fbf5a5d)
* fetch eslint config from repo (b15e79f1)
##### Documentation Changes
* **kitsu:**
* add node/legacy paths change to migration guide (7bcebcc3)
* link to package changelog (1cfed463)
* **readme:**
* fix link to kitsu-core readme (d28ec1f7)
* one-line badges (dfbf4c45)
* update readmes (bb824f89)
* **contributing:**
* update commit message formatting (b62603f4)
* add code style and commit message (7b5e16fe)
* **kitsu-core:**
* link to package changelog (35f1113e)
* add name for default exports (03356eb5)
* remove private flags (8099b9b1)
* link to github releases in root readme (9c71a30b)
##### New Features
* use node/legacy version of kitsu-core for node/legacy packages (8c77574c)
* split internal functions into a seperate package (a0bab704)
##### Refactors
* **kitsu-core:** optimise undefined checks (f5519551)
##### Code Style Changes
* fix spacing in auth example (489760dd)
* fix eslint issues (d1372b16)
* **eslint:** fix jest issues (d15c07bf)
### 4.6.0 (2018-02-12)
##### Chores
* **deps:** update documentation to ~5.4.0 ([#122](https://github.com/wopian/kitsu/pull/122)) ([d91434ee](https://github.com/wopian/kitsu/commit/d91434ee3e42b77f92358ba825d6accedfefe95e))
##### New Features
* include meta from relationships ([#118](https://github.com/wopian/kitsu/pull/118)) ([1add511c](https://github.com/wopian/kitsu/commit/1add511c552150421b91979da5d8cc160bc7b7f8))
#### 4.5.3 (2018-02-10)
##### Build System / Dependencies
* remove unused js-beautify devDependency ([708f15e8](https://github.com/wopian/kitsu/commit/708f15e8e3df36c4748c97e3e0bd6ef9fa4d546f))
##### Chores
* **deps:**
* update eslint-config-wopian to ~1.1.0 ([#120](https://github.com/wopian/kitsu/pull/120)) ([986b3732](https://github.com/wopian/kitsu/commit/986b3732f765d4816c5a4f1fc6a1d15b860240f3))
* update axios-mock-adapter to ~1.13.0 ([#119](https://github.com/wopian/kitsu/pull/119)) ([30da1e8a](https://github.com/wopian/kitsu/commit/30da1e8a4c8eddc43ebbf8944436b23588cddad5))
* update jest to ~22.2.0 ([#117](https://github.com/wopian/kitsu/pull/117)) ([f5165ba0](https://github.com/wopian/kitsu/commit/f5165ba0dc4f94e47a22af5c659eea30d5455720))
* update eslint-plugin-node to ~6.0.0 ([#116](https://github.com/wopian/kitsu/pull/116)) ([e7112ba5](https://github.com/wopian/kitsu/commit/e7112ba5a9204fce5acb53461c4c64cbce113b92))
* update rollup-plugin-babel-minify to ~4.0.0 ([#115](https://github.com/wopian/kitsu/pull/115)) ([41b8f4a6](https://github.com/wopian/kitsu/commit/41b8f4a6f113575e3bccae37f6d097b1975517d0))
* update eslint to ~4.17.0 ([#114](https://github.com/wopian/kitsu/pull/114)) ([571a168c](https://github.com/wopian/kitsu/commit/571a168c63827d2c7edb9aa5bb344ee3612ee9e5))
* update lock file ([#112](https://github.com/wopian/kitsu/pull/112)) ([bf24d5b2](https://github.com/wopian/kitsu/commit/bf24d5b281ea9c3c8422cb758f9a14a6ce71940c))
##### Documentation Changes
* **readme:**
* update browser section ([1452e7d1](https://github.com/wopian/kitsu/commit/1452e7d1336f4044ab745c4ad2759b47f3c432e3))
* add package size notice ([1f87617d](https://github.com/wopian/kitsu/commit/1f87617d9a54eefd1e20abd0a6aaa59904e48d94))
* **dictionary:** add JS destructuring ([a8dd1169](https://github.com/wopian/kitsu/commit/a8dd1169a004a53b1f2f329ae08b1357825e1caa))
* **migrating:** update error handling for 3.x to 4.x ([86a77130](https://github.com/wopian/kitsu/commit/86a77130948dc8563fcb3c45a9406883e9e4e23d))
* **changelog:** add revert notice to es module files ([dd83ed6c](https://github.com/wopian/kitsu/commit/dd83ed6c74a9d00ee5703c46a9c114cf53b41739))
##### New Features
* use eslint-config-wopian ([82d057cd](https://github.com/wopian/kitsu/commit/82d057cdec24329523037327882b5bb2186006c0))
##### Bug Fixes
* set browser usage cutoff to 0.05% instead of 0.5% for default usage ([dc1f8463](https://github.com/wopian/kitsu/commit/dc1f846352b92954b499caaf9a4caf954222f07f))
#### 4.5.2 (2018-01-27)
#### 4.5.1 (2018-01-27)
##### Build System / Dependencies
* add TypeError and addUncountableRule to dictionary ([118a430a](https://github.com/wopian/kitsu/commit/118a430aa94781fd54f2f6354daa963e425e7c04))
* run doc tasks before tests ([cdde056f](https://github.com/wopian/kitsu/commit/cdde056fa1a5d703baa7dc41c7fe337c47f76fb1))
##### Reverts
* re-add ES modules ([47037566](https://github.com/wopian/kitsu/commit/47037566a23160307b42da7e3cd47f067f8c4d49))
### 4.5.0 (2018-01-27)
##### Breaking Changes
* ~~remove ES module format~~ ([2d484e02](https://github.com/wopian/kitsu/commit/2d484e029c02cc8fda12ecda814af9c829c8b11b))
- reverted in `4.5.1`
* **fix:** rethrow JSON:API errors (fixes [#104](https://github.com/wopian/kitsu/pull/104)) ([4a3c6078](https://github.com/wopian/kitsu/commit/4a3c6078a4337115122f9c66691df058ddda53ee))
* **rollup:** ~~use commonjs format instead of UMD for lib files~~ ([204ab3e3](https://github.com/wopian/kitsu/commit/204ab3e3c93b21109f1515ae3ebc168b06181a7f))
- reverted in ([2dc27467](https://github.com/wopian/kitsu/commit/2dc274676abaf0b23a5d3ffb2b29b8278f44188a))
##### Build System / Dependencies
* lint docs during doc generation ([95c44478](https://github.com/wopian/kitsu/commit/95c4447802648fabbbc118e013eb1e6aba34a0f1))
##### Chores
* **deps:**
* update axios-mock-adapter to ~1.12.0 ([#108](https://github.com/wopian/kitsu/pull/108)) ([24ccbc77](https://github.com/wopian/kitsu/commit/24ccbc77f753b6316bce8f27a60d97e82456e3a9))
* update rollup to ~0.55.0 ([#105](https://github.com/wopian/kitsu/pull/105)) ([264f2009](https://github.com/wopian/kitsu/commit/264f2009cc678716148f1506dbc82e1752593963))
* remove useless throw case after 4a3c607 ([85e7cc67](https://github.com/wopian/kitsu/commit/85e7cc67287ca4d197874bcc91607bfa3027b80f))
##### Documentation Changes
* **readme:** update package size in support table ([978d0430](https://github.com/wopian/kitsu/commit/978d0430e11ec928cd02a0967b0b7189365843cf))
* **isAuth:** add deprecation notice ([c583889b](https://github.com/wopian/kitsu/commit/c583889bf42a5aca633885d0b6358cd0061d3685))
* **error:** add documentation ([97a35564](https://github.com/wopian/kitsu/commit/97a355641a4689165530d6ee446fc41cbf8df994))
* **query:** add documentation ([216a20d2](https://github.com/wopian/kitsu/commit/216a20d2750b42831f88536ef872ccb796050584))
* update dictionary ([27a3c341](https://github.com/wopian/kitsu/commit/27a3c341fc2ad533ba2538b938c5f2a6880f2539))
* add cdn usage and demo services (node & browser) ([671f7d34](https://github.com/wopian/kitsu/commit/671f7d348d2dd0ac1d61e03c661e95c7952a14d8))
* tag linkArray/Object as private functions ([601612c9](https://github.com/wopian/kitsu/commit/601612c92b1403e5c1e63a156cf2b021ffa573ba))
##### Refactors
* remove authentication requirements for post/patch/delete ([#107](https://github.com/wopian/kitsu/pull/107)) ([b91057e5](https://github.com/wopian/kitsu/commit/b91057e5bb50c6fb35fdc0125942824393e04f06))
* don't check query param type is a string ([a4486b3d](https://github.com/wopian/kitsu/commit/a4486b3d38a5e9771da7e5561422730bda879c50))
* cleanup linkRelationships ([c0e1aae8](https://github.com/wopian/kitsu/commit/c0e1aae84b57cac7e6ad295b1d2e65817438d899))
* inject JSON:API error array into top level of axios error ([d4019919](https://github.com/wopian/kitsu/commit/d4019919f1ecd8c78af57f8c55af333feead6ee6))
* simplify required jsonapi headers inclusion ([6f018c71](https://github.com/wopian/kitsu/commit/6f018c711d648f448e0c513e97add2a07c6a73f4))
##### Tests
* **error:** update test cases ([5ea1f130](https://github.com/wopian/kitsu/commit/5ea1f1302edde30d6b71b791bfff39c1be4c852d))
* ignore axios paramSerializer function line ([1a8dd927](https://github.com/wopian/kitsu/commit/1a8dd9272130e7f6a7b7b985df5aecf642aaa88d))
* test uncovered throw in serialise ([0b055d36](https://github.com/wopian/kitsu/commit/0b055d36c9797902c96c8b822835c82449220368))
* update test cases ([f974a2a0](https://github.com/wopian/kitsu/commit/f974a2a0b158635f785935d615bcb09cc551dea1))
#### 4.4.3 (2018-01-22)

@@ -2,0 +186,0 @@

151

package.json
{
"name": "kitsu",
"version": "5.0.0-beta.1",
"version": "5.0.0",
"description": "Simple & lightweight JSON-API client for Kitsu and other compliant APIs",
"license": "MIT",
"author": "James Harris <wopian@wopian.me>",
"main": "lib/kitsu.js",
"module": "lib/kitsu.mjs",
"main": "lib/index.js",
"module": "lib/index.mjs",
"engines": {
"node": ">=6"
},
"scripts": {
"docs": "documentation lint src/index.js",
"rollup": "cross-env NODE_ENV=production rollup -c --environment BUILD:production",
"build": "yarn rollup && size-limit",
"jest": "jest --coverage",
"spellcheck": "yaspeller-ci README.md MIGRATING.md CONTRIBUTING.md",
"lint": "eslint src && yarn spellcheck",
"test": "yarn jest && yarn lint && yarn docs && yarn build",
":test": "jest && yarn lint && yarn docs && yarn build",
":docs": "documentation readme src/index.js --section=API --sort-order alpha",
":commit": "git add package.json && git add README.md && git add CHANGELOG.md && git commit -m \"update changelog\"",
":publish": "git push origin && git push origin --tags && yarn publish",
":major": "yarn :test && yarn :docs && changelog -M && yarn :commit && npm version major && yarn :publish",
":minor": "yarn :test && yarn :docs && changelog -m && yarn :commit && npm version minor && yarn :publish",
":patch": "yarn :test && yarn :docs && changelog -p && yarn :commit && npm version patch && yarn :publish",
"example:basic": "node ./example/basic",
"example:async": "babel-node ./example/async",
"example:auth": "babel-node ./example/auth",
"example:complex": "babel-node ./example/complex"
},
"size-limit": [
{
"path": "./lib/kitsu.js",
"limit": "18 kb"
},
{
"path": "./lib/kitsu.mjs",
"limit": "18 kb"
},
{
"path": "./lib/legacy.js",
"limit": "20 kb"
},
{
"path": "./lib/node.js",
"limit": "15 kb"
},
{
"path": "./lib/node.mjs",
"limit": "15 kb"
}
],
"keywords": [

@@ -69,83 +27,42 @@ "kitsu",

],
"repository": {
"type": "git",
"url": "https://github.com/wopian/kitsu.git"
},
"bugs": {
"url": "https://github.com/wopian/kitsu/issues"
},
"homepage": "https://github.com/wopian/kitsu#readme",
"files": [
"lib"
],
"scripts": {
"docs:lint": "documentation lint src/index.js",
"docs:build": "documentation readme src/index.js --section=API --sort-order alpha",
"replace:node": "replace-in-file kitsu-core kitsu-core/node node/*.*js",
"replace:legacy": "replace-in-file kitsu-core kitsu-core/legacy legacy/*.js",
"replace": "yarn replace:node && yarn replace:legacy",
"rollup": "cross-env NODE_ENV=production rollup -c --environment BUILD:production",
"build": "yarn rollup && yarn replace"
},
"dependencies": {
"axios": "^0.17.0",
"babel-runtime": "^6.26.0",
"kitsu-core": "^5.0.0",
"pluralize": "^7.0.0"
},
"devDependencies": {
"axios-mock-adapter": "~1.11.0",
"babel-cli": "~6.26.0",
"babel-core": "~6.26.0",
"babel-eslint": "~8.2.0",
"babel-plugin-transform-runtime": "~6.23.0",
"babel-preset-env": "~1.6.0",
"babel-preset-stage-0": "~6.24.1",
"cross-env": "~5.1.0",
"documentation": "~5.3.3",
"eslint": "~4.16.0",
"eslint-config-standard": "~11.0.0-beta.0",
"eslint-plugin-import": "~2.8.0",
"eslint-plugin-jest": "~21.7.0",
"eslint-plugin-node": "~5.2.1",
"eslint-plugin-promise": "~3.6.0",
"eslint-plugin-standard": "~3.0.1",
"generate-changelog": "~1.7.0",
"jest": "~22.1.0",
"js-beautify": "~1.7.4",
"rollup": "~0.55.0",
"rollup-plugin-babel": "~3.0.1",
"rollup-plugin-babel-minify": "~3.1.2",
"rollup-plugin-local-resolve": "~1.0.7",
"size-limit": "~0.14.0",
"standard": "~10.0.2",
"yaspeller-ci": "~1.0.0"
},
"jest": {
"collectCoverageFrom": [
"src/**/*.js",
"!**/__cases__/**"
],
"coverageDirectory": "<rootDir>/coverage",
"moduleNameMapper": {
"^kitsu(.*)$": "<rootDir>/src/$1",
"^pkg$": "<rootDir>/package.json"
"size-limit": [
{
"path": "./lib/index.js",
"limit": "18 kb"
},
{
"path": "./lib/index.mjs",
"limit": "18 kb"
},
{
"path": "./legacy/index.js",
"limit": "20 kb"
},
{
"path": "./node/index.js",
"limit": "15 kb"
},
{
"path": "./node/index.mjs",
"limit": "15 kb"
}
},
"renovate": {
"extends": [
":npm",
":preserveSemverRanges",
":combinePatchMinorReleases",
":renovatePrefix",
":semanticCommits",
":semanticCommitTypeAll(chore)",
":rebaseStalePrs",
":unpublishSafe",
":prNotPending",
":automergeDisabled",
":maintainLockFilesMonthly",
":ignoreUnstable",
":updateNotScheduled",
":label(dependencies)",
":timezone(Europe/London)",
":assignee(wopian)",
"group:babelMonorepo",
"group:jestMonorepo",
"group:reactMonorepo",
"group:storybookMonorepo"
],
"prTitle": "update {{depName}} to {{newVersion}}",
"commitMessage": "update {{depName}} to {{newVersion}}"
}
]
}

@@ -17,3 +17,3 @@ # Kitsu

_Check out the [Migration Guide] for breaking changes and new features in `4.x`_
_Check out the [Migration Guide] for breaking changes and new features in `5.x`_

@@ -28,19 +28,14 @@ ## Features

## Install
## Node / Browser Support
```bash
yarn add kitsu
npm install kitsu
```
| Package | Package<br> Size\* | Node | Chrome | Firefox | Safari | Edge | IE |
| -------------: | :----------------: | :--: | :----: | :-----: | :----: | :--: | :-: |
| `kitsu` | 17.7 kb | 6+ | 49+ | 47+ | 9.1+ | 14+ | |
| `kitsu/legacy` | 19.7 kb | 6+ | 4+ | 3+ | 3.1+ | 12+ | 8+ |
| `kitsu/node` | 14.5 kb | 6+ | | | | | |
## Node / Browser Support
\* Including all dependencies, minified & gzipped
| Package | Package<br> Size | Node | Chrome | Firefox | Safari | Edge | IE |
| --------: | :--------------: | :--: | :----: | :-----: | :----: | :--: | :-: |
| [Default] | 17.9 kb | 6+ | 49+ | 57+ | 10.1+ | 15+ | |
| [Legacy] | 19.9 kb | 6+ | 4+ | 3+ | 3.1+ | 12+ | 8+ |
| Node | 14.5 kb | 6+ | | | | | |
[default]: http://browserl.ist/?q=last+2+years%2C+not+%3C+0.05%25
[default]: http://browserl.ist/?q=last+2+years%2C+not+%3C+0.5%25
[legacy]: http://browserl.ist/?q=last+10+years

@@ -50,3 +45,4 @@

A GET response by a JSON:API server returns:
<details>
<summary>A GET response by a JSON:API server</summary>

@@ -82,4 +78,7 @@ ```json5

A GET request with `kitsu` returns:
</details>
<details open>
<summary>A GET response with kitsu:</summary>
```json5

@@ -100,5 +99,14 @@ {

## Quick Start
</details>
```javascript
## Install
### Yarn / NPM
```bash
yarn add kitsu
npm install kitsu
```
```js
import Kitsu from 'kitsu' // ES Modules and Babel

@@ -108,21 +116,40 @@ const Kitsu = require('kitsu') // CommonJS and Browserify

const Kitsu = require('kitsu/lib/node') // Lighter node-only package
```
const api = new Kitsu() // For kitsu.io developers
[Try it on RunKit](https://runkit.com/embed/6mrx8ay7xuut)
const api = new Kitsu({ // For other JSON:API servers
baseURL: 'https://api.example/2' // e.g https://api.example/2
### Packd CDN
```html
<script src='https://bundle.run/kitsu@4?name=Kitsu'></script>
<script src='https://bundle.run/kitsu@4/lib/legacy.js?name=Kitsu'></script>
```
[Try it on CodePen](https://codepen.io/wopian/pen/RxmEeK?editors=0010)
## Quick Start
```javascript
// Kitsu.io's API
const api = new Kitsu()
// Other JSON:API servers
const api = new Kitsu({
baseURL: 'https://api.example/2'
})
const { data } = await api.get('anime') // Using with async/await
// Using with async/await
const res = await api.get('anime')
api.get('anime') // Using with Promises
.then(({ data }) => { ... })
.catch(err => throw err)
// Using with Promises
api.get('anime')
.then(res => { ... })
.catch(err => { ... })
// Fetching resources with get() or fetch()
api.get('anime', { params }, { headers }) // Collection of resources
api.get('anime/1') // Single resource
api.get('anime/1/episodes') // Single resource's relationship
// Fetching resources (get/fetch)
api.fetch('anime')
api.fetch('anime/1')
api.fetch('anime/1/episodes')
// Creating resources with post() or create()
// Creating resources (post/create)
api.create('post', {

@@ -132,3 +159,3 @@ content: 'some content'

// Updating resources with patch() or update()
// Updating resources (patch/update)
api.update('post', {

@@ -156,4 +183,4 @@ id: '1',

- [headers](#headers)
- [isAuth](#isauth)
- [patch](#patch)
- [plural](#plural)
- [post](#post)

@@ -165,5 +192,7 @@ - [remove](#remove)

Creates a new `kitsu` instance
**Parameters**
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Options
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Options (optional, default `{}`)
- `options.baseURL` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Set the API endpoint (default `https://kitsu.io/api/edge`)

@@ -178,9 +207,11 @@ - `options.headers` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Additional headers to send with requests

_Using with Kitsu.io's API_
```javascript
// If using Kitsu.io's API
const api = new Kitsu()
```
_Using another API server_
```javascript
// If using another API server
const api = new Kitsu({

@@ -191,4 +222,5 @@ baseURL: 'https://api.example.org/2'

_Setting headers_
```javascript
// Set a `user-agent` and an `authorization` token
const api = new Kitsu({

@@ -204,4 +236,3 @@ headers: {

Fetch resources
Aliases: `fetch`
Fetch resources (alias `fetch`)

@@ -223,4 +254,5 @@ **Parameters**

_Getting a resource with JSON:API parameters_
```javascript
// Get a specific user's name & birthday
api.get('users', {

@@ -236,4 +268,5 @@ fields: {

_Getting a collection of resources with their relationships_
```javascript
// Get a collection of anime resources and their categories
api.get('anime', {

@@ -244,43 +277,60 @@ include: 'categories'

_Getting a single resource by ID (method one)_
```javascript
// Get a single resource and its relationships by ID (method one)
api.get('anime', {
include: 'categories',
filter: { id: '2' }
api.get('anime/2', {
include: 'categories'
})
```
_Getting a single resource by ID (method two)_
```javascript
// Get a single resource and its relationships by ID (method two)
api.get('anime/2', {
include: 'categories'
api.get('anime', {
include: 'categories',
filter: { id: '2' }
})
```
_Getting a resource's relationship data only_
```javascript
// Get a resource's relationship data only
api.get('anime/2/categories')
```
_Handling errors (async/await)_
```javascript
// Handling errors (async/await)
// http://jsonapi.org/format/#error-objects
try {
const { data } = api.get('anime')
const { data } = await api.get('anime')
} catch (err) {
if (err.errors) err.errors.forEach(error => {
console.log(error) // Prints JSON:API error object
})
// Array of JSON:API errors: http://jsonapi.org/format/#error-objects
if (err.errors) err.errors.forEach(error => { ... })
// Error type (Error, TypeError etc.)
err.name
// Error message
err.message
// Axios request parameters
err.config
// Axios response parameters
err.response
}
```
_Handling errors (Promises)_
```javascript
// Handling errors (Promise)
// http://jsonapi.org/format/#error-objects
api.get('anime')
.then(res => res.data)
.then(({ data }) => { ... })
.catch(err => {
if (err.errors) err.errors.forEach(error => {
console.log(error) // Prints JSON:API error object
})
// Array of JSON:API errors: http://jsonapi.org/format/#error-objects
if (err.errors) err.errors.forEach(error => { ... })
// Error type (Error, TypeError etc.)
err.name
// Error message
err.message
// Axios request parameters
err.config
// Axios response parameters
err.response
})

@@ -297,14 +347,17 @@ ```

_Get all headers_
```javascript
// Receive all the headers
api.headers
```
_Get a single header's value_
```javascript
// Receive a specific header
api.headers['User-Agent']
```
_Add or update a header's value_
```javascript
// Add or update a header
api.headers['Authorization'] = 'Bearer 1234567890'

@@ -315,19 +368,5 @@ ```

#### isAuth
Check if the client is authenticated (oAuth2/Authorization header)
**Examples**
```javascript
if (api.isAuth) console.log('Authenticated')
else console.log('Not authenticated')
```
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**
#### patch
Update a resource
Aliases: `update`
Update a resource (alias `update`)

@@ -342,4 +381,5 @@ **Parameters**

_Update a post_
```javascript
// Update a user's post (Note: For Kitsu.io, posts cannot be edited 30 minutes after creation)
api.update('posts', {

@@ -353,6 +393,22 @@ id: '12345678',

#### plural
- **See: <https://www.npmjs.com/package/pluralize> for documentation**
- **See: Kitsu constructor options for disabling pluralization**
If pluralization is enabled (default, see Kitsu constructor docs) then pluralization rules can be added
**Examples**
_Adding an uncountable pluralization rule_
```javascript
api.plural.plural('paper') //=> 'papers'
api.plural.addUncountableRule('paper')
api.plural.plural('paper') //=> 'paper'
```
#### post
Create a new resource
Aliases: `create`
Create a new resource (alias `create`)

@@ -367,4 +423,5 @@ **Parameters**

_Create a post on a user's profile feed_
```javascript
// Post to a user's own profile
api.create('posts', {

@@ -397,4 +454,5 @@ content: 'Hello World',

_Remove a user's post_
```javascript
// Delete a user's post
api.remove('posts', 123)

@@ -408,4 +466,5 @@ ```

Get the authenticated user's data
Note: Requires the JSON:API server to support `filter[self]=true`
**Note** Requires the JSON:API server to support `filter[self]=true`
**Parameters**

@@ -420,9 +479,11 @@

_Get the authenticated user's resource_
```javascript
// Receive all attributes
api.self()
```
_Using JSON:API parameters_
```javascript
// Receive a sparse fieldset
api.self({

@@ -459,3 +520,3 @@ fields: 'name,birthday'

[changelog]: https://github.com/wopian/kitsu/blob/master/CHANGELOG.md
[changelog]: https://github.com/wopian/kitsu/blob/lerna/packages/kitsu/CHANGELOG.md

@@ -488,5 +549,5 @@ [contributing]: https://github.com/wopian/kitsu/blob/master/CONTRIBUTING.md

[david]: https://david-dm.org/wopian/kitsu
[david]: https://david-dm.org/wopian/kitsu?path=packages/kitsu
[david badge]: https://img.shields.io/david/wopian/kitsu.svg?style=flat-square
[david badge]: https://david-dm.org/wopian/kitsu/status.svg?path=packages/kitsu&style=flat-square

@@ -493,0 +554,0 @@ [david dev]: https://david-dm.org/wopian/kitsu?type=dev

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc