Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
快速api和颤振_Api_Flutter_Dart_Rapidapi - Fatal编程技术网

快速api和颤振

快速api和颤振,api,flutter,dart,rapidapi,Api,Flutter,Dart,Rapidapi,尝试在占星术应用程序中使用此api,虽然该食谱不适用于Flitter,但我正在尝试启动一个请求。 如果您能从rapid api获得这些数据并将其应用于颤振,我们将不胜感激,因为目前还没有相关的文档 import 'dart:convert'; import 'package:http/http.dart' as http; class APIService { // API key // Base API url static const String _baseUrl = &q

尝试在占星术应用程序中使用此api,虽然该食谱不适用于Flitter,但我正在尝试启动一个请求。 如果您能从rapid api获得这些数据并将其应用于颤振,我们将不胜感激,因为目前还没有相关的文档

import 'dart:convert';
import 'package:http/http.dart' as http;


class APIService {
  // API key
  // Base API url
  static const String _baseUrl = "https://sameer-kumar-aztro-v1.p.rapidapi.com/?sign=aquarius&day=today";
  // Base headers for Response url
  static const Map<String, String> _headers = {
  "x-rapidapi-key": "*****************",
    "x-rapidapi-host": "sameer-kumar-aztro-v1.p.rapidapi.com",
    
  };

  // Base API request to get response
  Future<dynamic> get() async {
    Uri uri = Uri.https(_baseUrl,"");
    final response = await http.get(uri, headers: _headers);
    if (response.statusCode == 200) {
      // If server returns an OK response, parse the JSON.
      print("success");
      return json.decode(response.body);
    } else {
      print("not success");
      // If that response was not OK, throw an error.
      throw Exception('Failed to load json data');
    }
  }
}
试试这个

Uri uri = Uri.parse(_baseUrl);
final response = await http.get(uri, headers: _headers);

不再使用get-use-post命令..

现在获取:403 E/flatter(27257):[ERROR:flatter/lib/ui/ui\u dart\u state.cc(186)]未处理的异常:异常:加载json数据失败感谢您这么多,它成功了
Uri uri = Uri.parse(_baseUrl);
final response = await http.get(uri, headers: _headers);