install:
npm i node-fetch
in config.js
insert this code:
exports.dokan = {
endpoint: 'https://www.test.com/wp-json/',
header: {
method: 'get',
headers: { 'Cache-Control': 'no-cache', 'Authorization': 'Bearer INSERT_YOUR_TOKEN_HERE' },
}
}
for routes file test.js
insert:
var config = require('./config.js');
var fetch = require('node-fetch');
exports.getAllStores = function(callback) {
fetch(config.dokan.endpoint + 'dokan/v1/stores/3', config.dokan.header)
.then(res => res.json())
.then(json => {
callback(json);
});
}
in test.js
you can change dokan/v1/stores/3 with your custom API from https://wedevsofficial.github.io/dokan/
in index.js
var test = require('./test');
router.get('YOUR_TRIGGER_URL', function(req, res, next) {
test.getAllStores(function(result) {
res.send(result);
});
});