Code: Select all
flutter: Error during registration: DioException [bad response]: This exception was thrown because the response has a status code of 307 and RequestOptions.validateStatus was configured to throw for this status code.
The status code of 307 has the following meaning: "Redirection: further action needs to be taken in order to complete the request"
Read more about status codes at https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
In order to resolve this exception you typically have either to verify and fix your request code or you have to fix the server code.
< /code>
Hier ist mein Flutterauth -Code < /p>
class AuthApi{
StorageManager storageManager =StorageManager();
AppInterceptor appInterceptor = AppInterceptor();
String authMsg = '';
final Dio _dio = Dio();
Future login(String email, String password) async {
try {
Response response = await _dio.post(APIs.tokenEndpoint,
data: { "email": email, "password": password},
options: Options(headers: {'Content-Type': 'application/json',}),
);
print(response.data);
if(response.statusCode == 200 || response.statusCode ==201){
var dataObj = LoginResponse.fromJson(response.data);
print(dataObj.email);
if (dataObj.token == null ||
dataObj.token == "") {
debugPrint("token is null");
return false;
}
storageManager.saveAccessToken(dataObj.token);
storageManager.saveUserRole(dataObj.role);
return true;
}else{
var data = jsonDecode(response.data);
authMsg = data["detail"];
return false;
}
} catch (e) {
return false;
}
}
}
< /code>
DIO in ein HTTP -Paket ändern, führte zu demselben Fehler < /p>
flutter: Registration failed with status: 307
https://drive.google.com/file/d/1-3bxtg ... sp=sharing
Ich habe das Gefühl, dass ich einige Einstellungen auf meiner Maschine ändern sollte! < /p>