flutterdartrapidapi

rapid api and flutter


trying to use this api in horoscope app, although the cookbook is not available for flutter but i am trying to initiate a request. any help in getting this data from rapid api into flutter will be much appreciated as there is no documentation available for this as of now.

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');
    }
  }
}

i am posting my error too just in case anyone wants:

    E/flutter (12728): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: FormatException: Invalid radix-10 number (at character 1)
E/flutter (12728): //sameer-kumar-aztro-v1.p.rapidapi.com/?sign=aquarius&day=today
E/flutter (12728): ^
E/flutter (12728): 
E/flutter (12728): #0      int._throwFormatException (dart:core-patch/integers_patch.dart:131:5)
E/flutter (12728): #1      int._parseRadix (dart:core-patch/integers_patch.dart:157:16)
E/flutter (12728): #2      int._parse (dart:core-patch/integers_patch.dart:100:12)
E/flutter (12728): #3      int.parse (dart:core-patch/integers_patch.dart:63:12)
E/flutter (12728): #4      _Uri._makeHttpUri (dart:core/uri.dart:1591:49)
E/flutter (12728): #5      new _Uri.https (dart:core/uri.dart:1462:12)
E/flutter (12728): #6      APIService.get (package:astrology_upload/api.dart:20:19)
E/flutter (12728): #7      _UploadState.initState (package:astrology_upload/Uploadpage.dart:22:7)
E/flutter (12728): #8      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4632:57)
E/flutter (12728): #9      ComponentElement.mount (package:flutter/src/widgets/framework.dart:4469:5)
E/flutter (12728): #10     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3541:14)
E/flutter (12728): #11     Element.updateChild (package:flutter/src/widgets/framework.dart:3306:18)
E/flutter (12728): #12     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5974:14)
E/flutter (12728): #13     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3541:14)
E/flutter (12728): #14     Element.updateChild (package:flutter/src/widgets/framework.dart:3306:18)
E/flutter (12728): #15     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4520:16)
E/flutter (12728): #16     Element.rebuild (package:flutter/src/widgets/framework.dart:4189:5)
E/flutter (12728): #17     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4474:5)
E/flutter (12728): #18     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4469:5)
E/flutter (12728): #19     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3541:14)
E/flutter (12728): #20     Element.updateChild (package:flutter/src/widgets/framework.dart:3306:18)
E/flutter (12728): #21     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5974:14)
E/flutter (12728): #22     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3541:14)
E/flutter (12728): #23     Element.updateChild (package:flutter/src/widgets/framework.dart:3306:18)
E/flutter (12728): #24     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5974:14)
E/flutter (12728): #25     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3541:14)
E/flutter (12728): #26     Element.updateChild (package:flutter/src/widgets/framework.dart:3306:18)
E/flutter (12728): #27     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4520:16)
E/flutter (12728): #28     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4667:11)
E/flutter (12728): #29     Element.rebuild (package:flutter/src/widgets/framework.dart:4189:5)
E/flutter (12728): #30     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4474:5)
E/flutter (12728): #31     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4658:11)
E/flutter (12728): #32     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4469:5)
E/flutter (12728): #33     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3541:14)
E/flutter (12728): #34     Element.updateChild (package:flutter/src/widgets/framework.dart:3306:18)
E/flutter (12728): #35     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5974:14)
E/flutter (12728): #36     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3541:14)
E/flutter (12728): #37     Element.updateChild (package:flutter/src/widgets/framework.dart:3306:18)
E/flutter (12728): #38     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5974:14)
E/flutter (12728): #39     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3541:14)
E/flutter (12728): #40     Element.updateChild (package:flutter/src/widgets/framework.dart:3306:18)
E/flutter (12728): #41     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4520:16)
E/flutter (12728): #42     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4667:11)
E/flutter (12728): #43     Element.rebuild (package:flutter/src/widgets/framework.dart:4189:5)
E/flutter (12728): #44     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4474:5)
E/flutter (12728): #45     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4658:11)
E/flutter (12728): #46     ComponentElement.mount (package:flutter/src/widgets/framewo

Solution

  • Instead of get use post command..