The dart code I compile is:
import 'dart:js';
import 'package:dio/dio.dart';
final Dio _dio = Dio();
class LoginResponse extends GenericResponse {
String? accessToken;
String? refreshToken;
LoginResponse(statusCode, this.accessToken, this.refreshToken)
: super(statusCode);
}
Future<LoginResponse> login(String phoneNumber, String password, String otp) async {
Response response = await _dio.post(
"https://example.com/token/obtain/",
data: {'phone_number': phoneNumber, 'password': password, 'otp': otp},
options: Options(validateStatus: (status) => status! < 500),
);
return LoginResponse(response.statusCode, response.data['access'], response.data['refresh']);
}
main() => context['loginFromDart'] = login;
I wish to access LoginResponse.accessToken
and LoginResponse.refreshToken
from the browser console. But still didn't find a way to do it.
from Cannot call compiled to JS async Dart function from browser console
No comments:
Post a Comment