How to implement favorite for posts in ionic creator using REST API


Dear ionic family,

I am new to ionic framework and ionic creator. I am currently working with ionic creator to create a brand new app with a pro account so I have access to code area to edit service and controller.

I am trying to implement Favorite feature for posts by using REST API through $http.

My Question:
How can I get device id?

Note: The reason I am not using local storage method because I want to store data in the database.

Favorite Table (structure):

  • FavoriteId
  • PostId
  • DeviceId

Please advise.

Thank you,



you can use this

No need to import anything. Just use directly like

class MyPage
constructor(){ … }

  var model = device.model;
  var deviceID = device.uuid;
  var string = device.version;