Hello i just started to use Ionic and i have some questions. First of all i downloaded an existing ionic project on GitHub to start. I do these commands and works fine.

$ git clone https://github.com/srinivastamada/ionic-restful-authentication.git
$ cd ionic-restful-authentication
$ npm install
$ ionic serve

The project starts at localhost:8100 as wanted. I understand that the files are on a cloud and the database too, right? When i download the files how can i use them so i may do some changes? I Mean i type in commands on NODE.JS command prompt?

The tutorial says that uses PHP-Restful-Api https://github.com/srinivastamada/PHP-Slim-Restful to connect to the database on XAMPP?
How do i connect the PHP-Slim-Restful to the Ionic Project?

Thanks

Recommended Answers

Hi,

are you following his tutorial? https://www.9lessons.info/2017/06/ionic-angular-php-login-restful-api.html
The part in which he writes about how to "Create an Authentication Service Provider" explains how to connect to the api.

Jump to Post

I'm sorry but cannot help here, I don't have experience with Angular & co.

Jump to Post

All 8 Replies

After i download the files on Github i put them on the htdocs folder on XAMPP and type localhost/ionic-restful-authentication/ to sow the output? Do i need some command on node.js command prompt? i mean i want to editthe files and watch my changes on localhost, how do i connect with PHP-Restful-Api?

Thanks Cereal i did and solved a lot. But i have two problems.

  1. I deleted the records on the database and still when i open the app it is logged in as a registered user. Is it a cookies thing?

  2. I am getting an infinite Please Wait when i make a new register as shown on the image i show you.

Hello SplitPane Provider
split-pane.ts:16:4
Angular is running in the development mode. Call enableProdMode() to enable the production mode.
core.js:3565
ionViewDidLoad Welcome
welcome.ts:29:4
Hello Common Provider
common.ts:14:4
Hello AuthService Provider
auth-service.ts:17:4
Native: tried calling StatusBar.styleDefault, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
util.js:60
Native: tried calling SplashScreen.hide, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
util.js:60
No access

Still getting an infinite Please wait
cordova_plugins.js Failed to load resource: the server responded with a status of 404 (Not Found)
localhost/:15 The key "viewport-fit" is not recognized and ignored.
cordova_plugins.js Failed to load resource: the server responded with a status of 404 (Not Found)
split-pane.ts:16 Hello SplitPane Provider
core.js:3565 Angular is running in the development mode. Call enableProdMode() to enable the production mode.
welcome.ts:30 ionViewDidLoad Welcome
util.js:60 Native: tried calling StatusBar.styleDefault, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
cordovaWarn @ util.js:60
util.js:60 Native: tried calling SplashScreen.hide, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
cordovaWarn @ util.js:60
common.ts:14 Hello Common Provider
auth-service.ts:15 Hello AuthServicePro Provider
home.ts:53 No access
ion-dev.js?v=3.1.2:120 Dev server logger closed
6livereload.js?snipver=1:74 WebSocket connection to 'ws://localhost:35729/livereload' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
exports.Connector.Connector.connect @ livereload.js?snipver=1:74
(anonymous) @ livereload.js?snipver=1:55
(anonymous) @ livereload.js?snipver=1:1152
t.invokeTask @ polyfills.js:3
r.runTask @ polyfills.js:3
e.invokeTask @ polyfills.js:3
i.isUsingGlobalCallback.invoke @ polyfills.js:3
n @ polyfills.js:3

Now i am getting these errors...

I'm sorry but cannot help here, I don't have experience with Angular & co.

I did a little research @cereal and i think the problem is here i am getting an error json.parse unexpected whitespace character after Json Data at line 1 column 2 of the json data

public authService: AuthService
  ) {
   ** const data = JSON.parse(localStorage.getItem("userData"));**
    this.userDetails = data.userData;
    this.userPostData.user_id = this.userDetails.user_id;
    this.userPostData.token = this.userDetails.token;
    this.userPostData.lastCreated = "";
    this.noRecords = false
    this.getFeed();
  }

You can't parse an array with Json.parse?

https://forum.ionicframework.com/t/show-login-data-on-another-page/112586/53
https://stackoverflow.com/questions/21515583/json-parse-unexpected-non-whitespace-character-after-json-data-in-javascript