Skip to content

Instantly share code, notes, and snippets.

@nparsons08 nparsons08/api_service.dart Secret

Created Mar 2, 2020
What would you like to do?
// mobile/lib/api_service.dart:16
Future<Map> login(String user) async {
var authResponse = await'$_baseUrl/v1/users', body: {'sender': user});
var authToken = json.decode(authResponse.body)['authToken'];
var feedResponse =
await'$_baseUrl/v1/stream-feed-credentials', headers: {'Authorization': 'Bearer $authToken'});
var feedToken = json.decode(feedResponse.body)['token'];
var chatResponse =
await'$_baseUrl/v1/stream-chat-credentials', headers: {'Authorization': 'Bearer $authToken'});
var chatToken = json.decode(chatResponse.body)['token'];
await platform.invokeMethod('setupChat', {'user': user, 'token': chatToken});
return {'authToken': authToken, 'feedToken': feedToken, 'chatToken': chatToken};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.