Type ‘String’ is not a subtype of type ‘int’ of ‘index’
Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
Step 1: Check your Flutter project API URL
body: new FutureBuilder<List>(
future: authServices.getUserProfile(),
builder: (context, snapshot) {
if (snapshot.hasError) print(snapshot.error);
print("yaha tak data");
print(snapshot.data);
if (snapshot.hasData) {
// Only display the first item in the list
var data = snapshot.data[0];
// return Text(data.toString());
return ItemList(list: snapshot.data);
} else {
return new Center(
child: new CircularProgressIndicator(),
);
}
},
));
Step 2: Check your Flutter project AuthServices page
Future<List> getUserProfile() async {
final prefs = await SharedPreferences.getInstance();
final key = 'token';
final value = prefs.get(key);
final pemail = 'email';
final pvalue = prefs.get(pemail);
print('dharmu ka data');
print(pvalue);
var url = Uri.parse(baseURL + 'get-user-profile/' + pvalue);
http.Response response = await http.get(url, headers: {
'Accept': 'application/json',
'Authorization': 'Bearer $value'
});
print(response.statusCode);
var getData = json.decode(response.body);
print('dharmu ka data aa raha hai');
print('yaha auth ka data');
print(getData);
return getData['data'];
}
Step 3: Go to the base URL with the API
This is right Code Here
public function getUserProfile(Request $request, $email){
Log::info('In DcotorController->getAllDoctors... user data aa raha hau');
$doctors = User::where('email', $email)->get();
$data = [
"status"=> "OK",
"data"=> $doctors,
];
Log::info('Response ja raha h yaha se bhi ja raha hai');
return response()->json($data, 200);
Log::info('Response ja raha h aa raha haai dharmu ka user');
}