Home > Blockchain >  Flutter Session - Get resaults by user session
Flutter Session - Get resaults by user session

Time:12-26

I have flutter app where user input data and that data is stored on mysql. Everything works perfect on my PHP, HTML on web. But in flutter I can't get session of user.

    Future getData() async {
var url = 'https://azer.maverus.ba/api/read.php';
var response = await http.get(Uri.parse(url));
return json.decode(response.body);

} I have that script and it read only data that I type inside flutter. And can't read data from database from curent user.

CodePudding user response:

You have to add header to pass Authorization key to the API check the code below

  Future getData() async {
    var url = 'https://azer.maverus.ba/api/read.php';
    var response = await http.get(Uri.parse(url),headers: <String, String>{
      "Authorization" : "YOUR KEY HERE"
    });
    return json.decode(response.body);
  }
  • Related