add put http
This commit is contained in:
parent
e320fccefa
commit
de527cb84b
@ -3,6 +3,7 @@ import 'events.dart';
|
|||||||
import '../variable/globals.dart' as globals;
|
import '../variable/globals.dart' as globals;
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
@ -10,10 +11,24 @@ mixin ShowDescImageAdd<T extends StatefulWidget> on State<T> {
|
|||||||
Future<void> addEvents(var events) async {
|
Future<void> addEvents(var events) async {
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
var accessToken = prefs.getString("access_token") ?? "";
|
var accessToken = prefs.getString("access_token") ?? "";
|
||||||
|
List<String> send = ["toto"];
|
||||||
|
|
||||||
if (accessToken.isNotEmpty) {
|
if (accessToken.isNotEmpty) {
|
||||||
var urlGet = Uri.parse("${globals.api}/events");
|
var urlPut = Uri.parse("${globals.api}/events");
|
||||||
var responseGet = await http.get(urlGet,
|
var responsePut = await http.put(urlPut,
|
||||||
headers: {HttpHeaders.cookieHeader: 'access_token=${accessToken}'});
|
headers: {HttpHeaders.cookieHeader: 'access_token=${accessToken}'},
|
||||||
|
body: jsonEncode({
|
||||||
|
'name': events["name"],
|
||||||
|
'place': events["place"],
|
||||||
|
'start_date': events['start_date'],
|
||||||
|
'end_date': events['start_date'],
|
||||||
|
'organizers': send,
|
||||||
|
'latitude': '0.0',
|
||||||
|
'longitude': '0.0',
|
||||||
|
}));
|
||||||
|
|
||||||
|
print("http put code status : ${responsePut.statusCode}");
|
||||||
|
print("http put body : ${responsePut.body}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user