API
The walker.js API destination allows you to send events to a custom API endpoint using walker.js library. This can be useful when you want to send data to a backend system for further processing or any external services.
Installation
- TypeScript
- Script
- Code
Install the destination via npm
npm i @elbwalker/destination-web-api
import { elb } from '@elbwalker/walker.js';
import destinationAPI from '@elbwalker/destination-web-api';
elb('walker destination', destinationAPI, config);
Load the destination via dynamic import
<script>
// Upload the dist/index.mjs on your own server
const destination = (
await import(
'https://cdn.jsdelivr.net/npm/@elbwalker/destination-web-api/dist/index.mjs'
)
).default;
elb('walker destination', destination, config);
</script>
Copy the code from the index.browser.js file
(function () {
'use strict';
var Destination = (() => {})(); // This is the copied code
elb('walker destination', Destination.default, config);
})();
Configuration
Set up the config for the destination.
const config = {
custom: {
url: 'https://httpbin.org/anything',
transform: (event, config, mapping) => {
return JSON.stringify(event);
},
transport: 'fetch',
},
};
Property | Type | Description |
---|---|---|
url* | string | URL to send the events to. |
transform | function | A function to transform the events before sending them to the URL. |
transport | fetch (default), xhr, beacon | The transport method to use when sending events. |
Properties with a *
are required.
info
If you need professional support with your walkerOS implementation, check out our services.