Appmixer SDK allows you to override any API method used by the SDK instance.
Setting a custom API option
Custom API is represented as an object composed of asynchronous methods that you set on your Appmixer SDK instance using the api option:
var myCustomApi = {/* the key must match an existing API method */myCustomApiMethod(/* arguments of the original method */) {returnnewPromise((resolve) => {resolve(myCustomResponse); }); }}/* Use a custom API on the entire SDK instance */var appmixer =newAppmixer({ api: myCustomApi });/* Use a custom API on a particular SDK UI widget */var designer =newappmixer.ui.Designer({ api: myCustomApi });
An example how to redefine the flow update request.
/* Create "Designer". */var designer =appmixer.ui.Designer({ el:'#your-designer', options:designerOptions(), api: {// extending the updateFlow requestupdateFlow(flowId, update) {// at this place you can call your own API every time the flow // gets updated// carefully catch errors, timeouts ... so calling your // external API does not affect the Designer behaviourconsole.log('Calling your own API.');console.log(JSON.parse(JSON.stringify(update)));// in order to update the flow in Appmixer, call the Flow APIreturnthis._request({ url:`${this.get('baseUrl')}/flows/${flowId}`, method:'PUT', data: update }); } }});