Created
February 1, 2023 11:05
-
-
Save Harrisonl/7bc82ea50bf5c0e6ea43df5dd286b145 to your computer and use it in GitHub Desktop.
Rella dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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