npm install strapi-sdk-javascript
import Strapi from 'strapi-sdk-javascript';
const strapi = new Strapi('http://localhost:1337');
await strapi.login('username_or_email', 's3cr3t');
// 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');
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);
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()
});
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)
createEntry(contentTypePluralized, data)
updateEntry(contentTypePluralized, id, data)
deleteEntry(contentTypePluralized, id)
searchFiles(query)
getFiles(params)
getFile(id)
upload(data)
Custom axios request configuration. See documentation
MIT
Generated using TypeDoc