Can anyone please show me the way to fetch data from localhost by OkHttp in Kotlin. When i changed url to https, it worked well
Picture in Logcat for successful one
but when i use http://localhost..., it failed to execute
Picture when failed
Can anyone please show me the way to fetch data from localhost by OkHttp in Kotlin. When i changed url to https, it worked well
Picture in Logcat for successful one
but when i use http://localhost..., it failed to execute
Picture when failed
EDIT - 8/23/22
It is likely you need to set
android:usesCleartextTraffic="true"
as a flag within the <application> element in the AndroidManifest.xml file.
Old Answer
don't use localhost like this. open command prompt if you are using Windows. type ipconfig and then get Local Ip Address and then use that Ip Address to get data from local host. same method for Mac. you have to get local ip address