Created
March 21, 2022 06:39
-
-
Save dev4jam/73139a3fb638fd40784643ef04850a2e to your computer and use it in GitHub Desktop.
Regular api call
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
final dio = Dio() | |
..options.baseUrl = 'https://www.domain.com/api'; | |
..options.connectTimeout = 5000; // 5 seconds | |
..options.receiveTimeout = 3000; // 3 seconds | |
try { | |
final response = await dio.post('/authenticate', data: {'login': 'user_name', 'password': 'password'}); | |
// Check response then response.data and convert response to your model | |
} on Dio.DioError catch (error) { | |
// Handle Dio exceptions here | |
} catch (error) { | |
// Handle generic exceptions here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment