Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

flutter fetch data from api example

Future<int> getSettings(int i) async {
    final url = Uri.parse(ApiLinks.settingsUrl + "/settings");

    try {
      http.Response response = await http.get(url,
          headers: {
            'Authorization': ApiLinks.token
          });
      if (response.statusCode == 200) {

        var  res = jsonDecode(response.body);
        //print(" res = "+res.toString());
        print(" res0 = "+res["StatusMessage"][i]["value_setting"].toString());
        return res["StatusMessage"][i]["value_setting"];
      }
      return 0;
    } catch (e) {
      print("Settings Api Get, error occurred " + e.toString());
      return 0;
    }
  }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #flutter #fetch #data #api
ADD COMMENT
Topic
Name
6+7 =