title: Flutter - How do I getJSON Data from NodeJS localhost?
body: <p>I have this JSON from my API in localhost</p>
  <pre><code>{&quot;username&quot;:&quot;coreadmin&quot;,&quot;password&quot;:&quot;adminAdmin&quot;,&quot;name_display&quot;:&quot;gm&quot;,&quot;role_id&quot;:1,&quot;position&quot;:&quot;admin&quot;,&quot;firstname&quot;:&quot;gm&quot;,&quot;lastname&quot;:&quot;gm&quot;,&quot;phone&quot;:&quot;1233-123-1233&quot;,&quot;email&quot;:&quot;test@admin.test&quot;,&quot;country&quot;:&quot;none&quot;,&quot;dt_created&quot;:&quot;2021-09-27T02:17:09.000Z&quot;,&quot;dt_updated&quot;:&quot;2021-09-27T02:17:09.000Z&quot;}
  </code></pre>
  <p>That data is displayed when I access it via web browser.</p>
  <p>I attempted to get the data and display it via flutter, here's my code :</p>
  <pre><code>import 'dart:async';
  import 'dart:convert';
  import 'package:http/http.dart' as http;
  
  import '../models/users.dart' as users_model;
  
  class FetchJson {      
    static Future&lt;users_model.Users&gt; fetchCredential(String username, String password) async {
      final response = await http.get(Uri.parse('http://localhost:7777/login?username=coreadmin&amp;password=adminADMIN'));
  
      if (response.statusCode == 200) {
        return users_model.Users.fromJson(jsonDecode(response.body));
      } else {
        throw Exception('Failed to load users credentials: ' + response.statusCode.toString());
      }
    }
  }
  </code></pre>
  <p>But there's no <code>response.body</code> while <code>response.statusCode == 200</code>
  The error is</p>
  <blockquote>
  <p>Error: FormatException: SyntaxError: Unexpected end of JSON input</p>
  </blockquote>