Answers for "open weather map http get"

0

open weather map http get

// include http dependency in pubspec.yaml
/*
 * https://pub.dev/packages/http/install
 * */
dependencies:
  http: ^0.13.1
    
// import http in the dart file where you will be interacting with it
import 'package:http/http.dart' as http;

// use http
/*
 * you will get your {key} from https://openweathermap.org/
 write the key without the braces {}
 
 if you run into any Uri issues: https://stackoverflow.com/questions/55995791/how-can-i-resolve-the-argument-type-string-cant-be-assigned-to-the-parameter
 
 * */

String url =
      'https://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid={key}';
  Future<String> getData() async {
    var response =
        await http.get(Uri.parse(url), headers: {"Accept": "application/json"});
    print(response.body);

    return "Success";
  }
Posted by: Guest on April-13-2021
0

open weather map http get

// include http dependency in pubspec.yaml
/*
 * https://pub.dev/packages/http/install
 * */
dependencies:
  http: ^0.13.1
    
// import http in the dart file where you will be interacting with it
import 'package:http/http.dart' as http;

// use http
/*
 * you will get your {key} from https://openweathermap.org/
 write the key without the braces {}
 
 if you run into any Uri issues: https://stackoverflow.com/questions/55995791/how-can-i-resolve-the-argument-type-string-cant-be-assigned-to-the-parameter
 
 * */

String url =
      'https://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid={key}';
  Future<String> getData() async {
    var response =
        await http.get(Uri.parse(url), headers: {"Accept": "application/json"});
    print(response.body);

    return "Success";
  }


//How to start to work with Openweather API - OpenWeatherMaphttps://openweathermap.org › appid
Posted by: Guest on April-13-2021

Code answers related to "Dart"

Browse Popular Code Answers by Language