I have created an app using flutter for UI and Restapi in nodejs as the backend. Now i want to verify the user, who signuped with the firebase authentication,the sending the current user's firebase Id token. In order, to do this I am sending the id token using the HTTP Post method. But got an error.
Sample code:
import 'package:http/http.dart' as http;
FirebaseUser user = await FirebaseAuth.instance.currentUser();
if(user!=null){
Future<IdTokenResult> idtoken = user.getIdToken();
}
http.Response response = await http.post("https://www.something.com/something/something",
body:jsonEncode({
"name": name.text,
"pincode": "$pincode",
"token": idtoken,
"phone": "${widget.phoneNo}",
}),
headers: {'Content-Type': 'application/json'},
);
Got Error:
Unhandled Exception: Converting object to an encodable object failed: Instance of 'Future<IdTokenResult>'
P.S: Suggest an edit, if something wrong with the question, I am for ideas (Thanks for the help in advance :) )