|
|
- // import 'package:sqflite/sqflite.dart';
- import 'package:http/http.dart' as http;
- import 'dart:convert';
- import "package:pointycastle/export.dart";
- import '/models/friends.dart';
- import '/utils/storage/encryption_keys.dart';
- import '/utils/storage/session_cookie.dart';
-
- void getFriends() async {
- RSAPrivateKey privKey = await getPrivateKey();
-
- final resp = await http.get(
- Uri.parse('http://192.168.1.5:8080/api/v1/auth/friends'),
- headers: {
- 'cookie': await getSessionCookie(),
- }
- );
-
- if (resp.statusCode != 200) {
- throw Exception(resp.body);
- }
-
- List<Friend> friends = [];
-
- List<dynamic> friendsJson = jsonDecode(resp.body);
-
- for (var i = 0; i < friendsJson.length; i++) {
- friends.add(
- Friend.fromJson(
- friendsJson[i] as Map<String, dynamic>,
- privKey,
- )
- );
- }
-
- print(friends);
- }
-
|