Created
April 9, 2020 19:59
-
-
Save parzibyte/13c297b3e9bb8283bb8cf24351ec74f1 to your computer and use it in GitHub Desktop.
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
Future<bool> eliminarProducto(String id) async { | |
log("Obteniendo prefs..."); | |
final prefs = await SharedPreferences.getInstance(); | |
String posibleToken = prefs.getString("token_api"); | |
log("Posible token: $posibleToken"); | |
if (posibleToken == null) { | |
log("No hay token"); | |
return false; | |
} | |
log("Haciendo petición..."); | |
final http.Response response = await http.delete( | |
"$RUTA_API/producto/$id", | |
headers: <String, String>{ | |
'Content-Type': 'application/json; charset=UTF-8', | |
'Authorization': 'Bearer $posibleToken', | |
}, | |
); | |
log("Response es 200?"); | |
log((response.statusCode == 200).toString()); | |
return response.statusCode == 200; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment