Usage
Learn how to use this SDK. ๐
New instance
Here is how you can instantiate the Strapi SDK.
import Strapi from "strapi-sdk-js"
const strapi = new Strapi()
Check out the Options page for available options.
Content Types
All contentTypes methods are built based on the default Strapi CRUD operations.
await strapi.find("restaurants", { ...params })
Check out the CRUD Methods section for more information.
Authentication
The SDK comes with all the methods needed to handle authentication. You can find below the list of all the methods available:
register
login
changePassword
forgotPassword
resetPassword
sendEmailConfirmation
getProviderAuthenticationUrl
authenticateProvider
logout
setUser
fetchUser
getToken
setToken
removeToken
Check out the Authentication Methods section for more information.
Advanced
Accessing user
Once you're logged in, you can access the user
object which contains details about authenticated user through the strapi.user
property.
Accessing axios
This SDK uses axios
under the hood, you can directly access the axios
instance through the strapi.axios
property.
Custom request
If you've defined custom routes in your Strapi API that go beyond the REST scope, or if you want to extend the axios
request configuration, you can do as below:
const response = await strapi.request("get", "/restaurants", {
headers: {
foo: "bar",
},
})
See the axios config