NodeJS Library Quickstart
Configure Project
- First install the npm library in your project.
npm i @dapi-co/dapi-node
- Import Dapi's library in your code.
import DapiApp from '@dapi-co/dapi-node'
const DapiApp = require('@dapi-co/dapi-node')
- Create a Dapi app with your App Secret
import DapiApp from '@dapi-co/dapi-node'
const dapi = new DapiApp({
appSecret: 'YOUR_APP_SECRET',
})
const DapiApp = require('@dapi-co/dapi-node')
const dapi = new DapiApp.default({
appSecret: 'YOUR_APP_SECRET',
})
- Now you can use any of the functions of the DapiApp instance,
dapi
. Here is an example forgetAccounts
.
const DapiApp = require('@dapi-co/dapi-node')
const dapi = new DapiApp.default({
appSecret: 'YOUR_APP_SECRET',
})
try {
dapi.data.getAccounts('ACCESS_TOKEN', 'USER_SECRET')
.then(accounts_response => {
console.log(accounts_response)
//do something with the response
})
} catch (error) {
console.dir(error)
}
Updated about 1 year ago