Types & Errors

Request And Response Types

The SDK exports all request and response types as TypeScript interfaces. Simply import them using the MMG namespace:

import { MMG } from "mobile-money-sdk";
const request: MMG.PostECommerceLoginMerRequest = {
// ... your request data
};

Exception Handling

When the API returns a non-success status code (4xx or 5xx response), a subclass of MMGError will be thrown. You can catch these errors to inspect the status code and raw response.

import { MMGError } from "mobile-money-sdk";
try {
await client.authentication.loginResourceTokenApi(...);
} catch (err) {
if (err instanceof MMGError) {
console.log(err.statusCode);
console.log(err.message);
console.log(err.body);
console.log(err.rawResponse);
}
}