skip to Main Content

When using get request in flutter using dio
Even though host/url is correct it still showed error saying invalid host
I was fetching data from data base and present it in a table using django

The data fetched using get is visible in browser howsoever

The post request runs without issue

2

Answers


  1. AndroidManifest.xml

    <manifest xmlns:android...>
    <uses-permission android:name="android.permission.INTERNET" /> //add this line
    <application ...
    </manifest>
    
    Login or Signup to reply.
  2. I faced a issue where data from Django rest framework was not showing in Flutter through Dio. But in Postman everything was alright.

    I thought problem was in Flutter. Then I found out I didn’t allowed host in Django settings.py file. I added this

    ALLOWED_HOSTS = [
    '10.0.2.2',
    '127.0.0.1',
    ]
    

    and at the end of the file added this
    CORS_ALLOW_ALL_ORIGINS = True

    It solved my problem.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search