0.5.9 • Published 3 years ago

@autom8apps/strapi-sdk-javascript v0.5.9

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

DESCRIPTION

This is a duplicated version of the no longer maintained strapi javascript sdk

USE WITH CAUTION: I revamped the no longer supported project because I didn't want to build my own SDK and I wanted something I could use for my various personal projects. I have no intention at the moment of supporting this package for the long term. Install at your own discretion.


Install

npm install @autom8apps/strapi-sdk-javascript

Start now

New instance

import Strapi from '@autom8apps/strapi-sdk-javascript';

const strapi = new Strapi('http://localhost:1337');

Authentications

Local

await strapi.login('username_or_email', 's3cr3t');

Providers

// Redirect your user to the provider's authentication page.
window.location = strapi.getProviderAuthenticationUrl('facebook');

Once authorized, the provider will redirects the user to your app with an access token in the URL.

// Complete the authentication: (The SDK will store the access token for you)
await strapi.authenticateProvider('facebook');

You can now fetch private APIs

const posts = await strapi.getEntries('posts');

Files management

Browser

const form = new FormData();
form.append('files', fileInputElement.files[0], 'file-name.ext');
form.append('files', fileInputElement.files[1], 'file-2-name.ext');
const files = await strapi.upload(form);

Node.js

const FormData = require('form-data');
const fs = require('fs');
const form = new FormData();
form.append('files', fs.createReadStream('./file-name.ext'), 'file-name.ext');
const files = await strapi.upload(form, {
  headers: form.getHeaders()
});

Functions/Methods

Strapi(baseURL, storeConfig, requestConfig)

request(method, url, requestConfig)

register(username, email, password)

login(identifier, password)

forgotPassword(email, url)

resetPassword(code, password, passwordConfirmation)

getProviderAuthenticationUrl(provider)

authenticateProvider(provider, params)

setToken(token, comesFromStorage)

clearToken(token)

getEntries(contentTypePluralized, params)

getEntry(contentTypePluralized, id)

getEntryCount(contentTypePluralized, params)

createEntry(contentTypePluralized, data)

updateEntry(contentTypePluralized, id, data)

deleteEntry(contentTypePluralized, id)

searchFiles(query)

getFiles(params)

getFile(id)

upload(data)

requestConfig

Custom axios request configuration. See documentation

Resources

Credits

License

MIT

0.5.8

3 years ago

0.5.7

3 years ago

0.5.9

3 years ago

0.5.4

3 years ago

0.5.6

3 years ago

0.5.5

3 years ago

0.5.3

4 years ago

0.5.1

4 years ago