Future<String> obtenerVentas() async { | |
setState(() { | |
this.cargando = true; | |
}); | |
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 "No hay token"; | |
} | |
log("Haciendo petición..."); | |
var response = await http.get( | |
"$RUTA_API/ventas", | |
headers: <String, String>{ | |
'Content-Type': 'application/json; charset=UTF-8', | |
'Authorization': 'Bearer $posibleToken', | |
}, | |
); | |
this.setState(() { | |
cargando = false; | |
ventas = json.decode(response.body); | |
}); | |
return "Success!"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment