Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

🔌 Official JavaScript SDK for APIs built with Strapi.

License

NotificationsYou must be signed in to change notification settings

strapi/strapi-sdk-javascript

Repository files navigation

⚠️ This package not up to date and maintained⚠️

We recommend you not to use this package. We stopped to maintained it by lack of time and also because the features provided by this SDK are the same as a good HTTP client well configured.So I suggest you use the best HTTP client for the technology you use. To configure it to target your Strapi API.Here so usefull ressources to help you:


The official Strapi SDK for JavaScript, available for browsers or Node.js backends.



Install

npm install strapi-sdk-javascript

Start now

New instance

importStrapifrom'strapi-sdk-javascript';conststrapi=newStrapi('http://localhost:1337');

Authentications

Local

awaitstrapi.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)awaitstrapi.authenticateProvider('facebook');

You can now fetch private APIs

constposts=awaitstrapi.getEntries('posts');

Files management

Browser

constform=newFormData();form.append('files',fileInputElement.files[0],'file-name.ext');form.append('files',fileInputElement.files[1],'file-2-name.ext');constfiles=awaitstrapi.upload(form);

Node.js

constFormData=require('form-data');constfs=require('fs');constform=newFormData();form.append('files',fs.createReadStream('./file-name.ext'),'file-name.ext');constfiles=awaitstrapi.upload(form,{headers:form.getHeaders()});

API

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

Roadmap

  • GraphQL
  • Attach/Detach entry relationship
  • Real time with Socket.io

Credits

License

MIT

About

🔌 Official JavaScript SDK for APIs built with Strapi.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors9


[8]ページ先頭

©2009-2025 Movatter.jp