flutter_js
flutter_js copied to clipboard
How to make an API call?
Need HELP!!!
Hi, I am trying to make an API call and get the data(object returned by API) in dart/flutter so that I can use the data to populate my layout. How do I do this?
what I am trying right now
jsRuntime.evaluate("""
console.log('evaluate');
const fn = async () => {
console.log('fn called');
const response = await fetch('https://reqres.in/api/users?page=2');
const body = await response.json();
console.log("body ",body);
}
fn();
""");
In the above code evaluate and fn called print but the body never prints and if so how would I get the body in dart code?
please help.