Skip to content

Instantly share code, notes, and snippets.

@Harrisonl
Created February 1, 2023 11:05
Show Gist options
  • Save Harrisonl/7bc82ea50bf5c0e6ea43df5dd286b145 to your computer and use it in GitHub Desktop.
Save Harrisonl/7bc82ea50bf5c0e6ea43df5dd286b145 to your computer and use it in GitHub Desktop.
Rella dart
import 'dart:convert';
import 'package:http/http.dart' as http;
const url = "https://ingestion.rella.so/i/events";
const HTTP_METHOD = "POST";
const apiKey = "key here";
Future<void> makeRequest(Map<String, dynamic> payload) async {
final response = await http.post(
url,
headers: {
'Content-Type': "application/json",
'Authorization': apiKey
},
body: jsonEncode(payload)
);
if (response.statusCode != 200) {
throw Exception('Failed to make request');
}
}
// You can then use it:
final payload = {
"type": "user-registered",
"title": "User Registered",
"msg": "Bobby Jones has registered",
"milestone": true,
"icon": "🎉",
"tags": {
"email": "bobby@tables.com",
"userID": "1"
}
};
await makeRequest(payload);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment