Connect to a front-end

We enable every MAPT Project to use our CreateAppEvent and UpdateAppEvent microservices. It allows users to connect their front-end sites and apps to MAPT easily.

This is because CreateAppEvent is a synchronous call which will return the final data from UpdateAppEvent .

This is how it would/could look for your first microservice in MAPT (our No-Code builder):

Sending an event to CreateAppEvent

The format of the input data should be as follows:

The URL for this microservice is https://api.mapt.events/create_app_event.

You will also need to send your MAPT API Key in the Authorization header.

Here is NodeJS code to show an example of how to send the event to the CreateAppEvent microservice:

const fetch = require('node-fetch');exports.handler = async event => {    const {event_type, input, ApiKey} = event;    const raw_response = await fetch("https://api.mapt.events/create_app_event", {        method: "post",        body: JSON.stringify({event_type, input}),        headers: {            'Authorization': "Bearer " + ApiKey}`,            'Content-Type': 'application/json'        },    });    const response = await raw_response.json();    console.log(JSON.stringify(response));    if(raw_response.status !== 200) throw Error('Invoke API error');        return response;}

The CreateAppEvent microservice will add the input Object to data, and also add the new properties created_at and id.

Here is an example:

"data": {	"input": {...},	"created_at": "2022-11-15T12:55:28.982Z",	"id": "e64c197a-5337-4950-b2b2-4089897bb53d"}

Please make sure your micrservices preserve these properties as they will be needed when invoking UpdateAppEvent. Your microservices should only be appending data anyway, not removing.

Now you're ready to build...