flutter中的音频包如何将base-url与这段代码中的url和apikey连接起来。我对音频包的工作原理有点困惑,有人能帮帮我吗
如果我有一个这样的URL
BaseURL = "https://newsapi.org/"
apkikey = "256c198308134b578e338737a895"
url= "v2/top-headlines?country=us"dio包如何将上述三个组件结合在一起,以生成如下所示的这种url
https://newsapi.org/v2/top-headlines?country=us&apikey=256c198308134b578e338737a895
任何帮助都将不胜感激
发布于 2021-09-14 11:35:03
就像这样,ArticleResponse就是模型
BaseURL = "https://newsapi.org/v2/"
getTopHeadLinesUrl = "$BaseURL/top-headlines";
apkikey = "256c198308134b578e338737a895"
Future<ArticleResponse> getTopHeadlines() async {
var params = {"apiKey": apikey, "country": "us"};
try {
Response response = await _dio.get(getTopHeadLinesUrl, queryParameters: params);
return ArticleResponse.fromJson(response.data);
} catch (e) {
return ArticleResponse.withError(e.toString());
}
}
Example:
"https://newsapi.org/v2/top-headlines?country=us&apiKey=509ea7c380274d5b9ae18c7a3fe9af7c"请注意,您每天只有100个请求
https://stackoverflow.com/questions/69175032
复制相似问题