Sherpa.js is a pure JavaScript library that helps consuming a sherpa API.
Available as npm package sherpajs.
Use sherpats if you want to generate a typescript client library module from sherpadoc.
You need to know the baseURL for the API, e.g. "https://www.sherpadoc.org/example/".
sherpa.load('https://www.sherpadoc.org/example/')
.then(function(example) {
example.requestCount()
.then(function(result) {
alert('Number of requests: '+result);
}, function(error) {
alert('Error: '+JSON.stringify(error));
});
}, function(error) {
alert('Error loading API: '+JSON.stringify(error));
});
Or if you know the functions you need:
var sherpaJSON = {functions: ['requestCount']} // loaded from https://www.sherpadoc.org/example/sherpa.json
var example = sherpa.init('https://www.sherpadoc.org/example/', sherpaJSON);
example.requestCount()
.then(function(result) {
alert('Number of requests: '+result);
}, function(error) {
alert('Error: '+JSON.stringify(error));
});