mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-10 03:57:39 +08:00
feat: add auth header
This commit is contained in:
@@ -39,6 +39,7 @@ class APIs {
|
||||
}
|
||||
|
||||
static Dio? dio1;
|
||||
static Map<String, String> authHeaders = {};
|
||||
|
||||
static Future<Dio> getDio() async {
|
||||
if (dio1 != null) {
|
||||
@@ -46,6 +47,9 @@ class APIs {
|
||||
}
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
var token = prefs.getString("token");
|
||||
|
||||
authHeaders["Authorization"] = "Bearer $token";
|
||||
|
||||
var dio = Dio();
|
||||
dio.interceptors.add(InterceptorsWrapper(
|
||||
onRequest: (options, handler) {
|
||||
|
||||
Reference in New Issue
Block a user