Domain Setting
File locate: ./app/configs/settings.js
Setting.domain
: define API url in here, default is https://demo.listarapp.com

Suffix API
This file has defined all API suffix for all functions of this project
File locate: ./app/api/index.js

Network Connection
File locate: ./app/api/http.js
setupInterceptors() {
const api = axios.create({
timeout: 30000,
});
api.interceptors.request.use(
config => {
const token = getToken();
const device = getDevice();
if (!config.baseURL) {
config.baseURL = `${getDomain()}/index.php/wp-json`;
}
console.log('Before Request >>>', config);
// Add more config before request
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
if (device) {
config.headers.appVersion = device.appVersion;
config.headers.brand = device.brand;
config.headers.buildNumber = device.buildNumber;
config.headers.bundleId = device.bundleId;
config.headers.deviceId = device.deviceId;
config.headers.deviceType = device.deviceType;
config.headers.model = device.model;
config.headers.systemName = device.systemName;
config.headers.systemVersion = device.systemVersion;
config.headers.token = device.token;
config.headers.model = device.model;
}
return config;
},
error => {
console.log('Error Request >>>', error);
// Do something with response error
return new Promise.reject(error);
},
);
api.interceptors.response.use(
response => {
console.log('After Request >>>', response);
// process more after response
return response;
},
error => {
console.log('Error Response >>>', error);
// process more when exception
const code = error.response?.data?.code;
if (this.exceptionCode.includes(code)) {
Navigator.popToTop();
store.dispatch(authActions.onExpire());
}
return new Promise.reject(error);
},
);
return api;
}
The application is using axios for control network connection. You can refer this npm package for understand more in detail how dose it work https://www.npmjs.com/package/axios