79669897

Date: 2025-06-18 00:47:40
Score: 1
Natty:
Report link

export const apiClient = axios.create({
  baseURL: 
    `http://${Platform.OS == 'android' ? '10.0.2.2' : 'localhost'}:8080/api/v1`,
});

When using an Android emulator (AVD), localhost refers to the emulator itself, not your computer. To access a server running on your host machine, use 10.0.2.2 instead of localhost. This fixed the issue for me.

Reasons:
  • Has code block (-0.5):
  • Starts with a question (0.5): When
  • Low reputation (1):
Posted by: Ahmed Habib