Skip to content

Custom Transport

Provide transport when the backend contract does not match the default JSON transport.

mountForm(container, {
schema,
transport: {
async submit(request) {
const result = await modelClient.predict({
values: request.serializedValues,
signal: request.signal,
});
return {
reports: {
prediction: result.prediction,
},
meta: {
requestId: result.requestId,
},
};
},
},
});

Use createJsonTransport(...) only when the backend matches MLForm’s default JSON contract. Otherwise keep a custom transport.