Skip to content

Commit

Permalink
updated cf code
Browse files Browse the repository at this point in the history
  • Loading branch information
bulgariamitko committed Mar 29, 2024
1 parent 7f3f3d4 commit dad33a3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// YouTube channel - https://www.youtube.com/@flutterflowexpert
// video - no
// paid video - https://youtu.be/Y82DsIHiPNI
// Join the Klaturov army - https://www.youtube.com/@flutterflowexpert/join
// Support my work - https://github.com/sponsors/bulgariamitko
// Website - https://bulgariamitko.github.io/flutterflowtutorials/
// You can book me as FF mentor - https://calendly.com/bulgaria_mitko
// GitHub repo - https://github.com/bulgariamitko/flutterflowtutorials
// Discord channel - https://discord.gg/G69hSUqEeU


async function handleRequest(request) {
const country = request.headers.get('CF-IPCountry');

Expand Down
24 changes: 24 additions & 0 deletions CloudFlare/Country/fetch-country.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// YouTube channel - https://www.youtube.com/@flutterflowexpert
// paid video - https://youtu.be/Y82DsIHiPNI
// Join the Klaturov army - https://www.youtube.com/@flutterflowexpert/join
// Support my work - https://github.com/sponsors/bulgariamitko
// Website - https://bulgariamitko.github.io/flutterflowtutorials/
// You can book me as FF mentor - https://calendly.com/bulgaria_mitko
// GitHub repo - https://github.com/bulgariamitko/flutterflowtutorials
// Discord channel - https://discord.gg/G69hSUqEeU

import 'package:http/http.dart' as http;

Future<dynamic> fetchCountry() async {
final response = await http
.get(Uri.parse('https://location-country.bulgaria-mitko.workers.dev/'));

dynamic data = {'country': 'no location'};

if (response.statusCode == 200) {
// If server returns an OK response, parse the JSON
data = jsonDecode(response.body);
}

return data;
}

0 comments on commit dad33a3

Please sign in to comment.