Created
December 5, 2022 10:58
-
-
Save nbnD/13bbeaf86a2279c5aaab35ffa8126043 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import 'package:http/http.dart' as http; | |
Future<String> getIdToken({bool? force}) async { | |
// fetch update token | |
return "abc*******"; | |
} | |
Future<void> main() async { | |
final client = http.Client(); | |
final token = await getIdToken(); | |
final response = getRequest(client, token); | |
if (response.statusCode == 401) { | |
getRequest(client, token); | |
} else { | |
///other process | |
} | |
} | |
getRequest(client, token) async { | |
await client.get(Uri.parse("https://senkyaku.jp"), | |
headers: {"Authorisation": "Bearer $token"}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment