The API runs on an external server.
And I have inserted in ionic.project file
"proxies": [
{
"path": "/v1",
"proxyUrl": "https://myextsite.com/api/public/index.php/v1"
}
]
In my app.js I have:
.constant('SERVER', {
//url: 'https://myextsite.com/api/public/index.php/v1'
url: 'v1'
})
Compiled on the smartphone or the local environment, the 2 urls of the constant SERVER work, except for the Ionic View App.
Here’s an example of request in my application:
var cred = {
email: credentials.email,
password: credentials.password,
_token: TokenService.getToken()
};
$http.post(SERVER.url + "/login", cred)
.success(function(response)
{
usr.isAuth = response.data.success;
usr.username = response.data.user;
usr.password = response.data.password;
cacheSession();
})
.error(function(err)
{
uncacheSession();
});