Reputation: 19
I feel kinda dumb asking this. Because I was able to parse Maps and Lists from the api but I have no idea how to use something as simple as a double from the same api.
I simply want to make a
double yld;
from this api link,
Upvotes: 0
Views: 601
Reputation: 7670
The response body is a String
so you'll have to parse it into a double
using double.parse()
getYld() async {
var url = 'https://sandbox.iexapis.com/stable/data-points/market/DGS10?
token=Tsk_38ddda0b877a4510b42a37ae713cdc96';
var res = await http.get(url);
if (res.statusCode == 200) {
double yld = double.parse(res.body); // parse the double here
}
}
Upvotes: 1