Sends a network request through JSBridge.
Network request parameters.
The network response containing the result data or error information. See SendResponse.
import { NetworkModule, isSuccess, isError, hasResult } from '@grabjs/superapp-sdk';
// Initialize the network module
const network = new NetworkModule();
// Send a POST request with headers and body
const response = await network.send({
endpoint: 'https://api.example.com/users',
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: { name: 'John', email: 'john@example.com' },
timeout: 30
});
// Handle the response
if (isSuccess(response) && hasResult(response)) {
console.log('Success:', response.result);
} else if (isError(response)) {
console.error(`Error ${response.status_code}: ${response.error}`);
} else {
console.error('Unhandled response');
}
SDK module for making network requests through the native layer via
JSBridge.Remarks
Provides access to native network functionality for making HTTP requests. This module is only for MiniApps hosted on the Grab domain to call authenticated Grab API endpoints. It should not be used by external MiniApps (not on Grab domain) or for non-authenticated Grab APIs. This code must run on the Grab SuperApp's WebView to function correctly.
Example
ES Module:
Example
CDN (UMD):