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


#1

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,

Peter


#2

you can use this

No need to import anything. Just use directly like

class MyPage
{
constructor(){ … }

getDeviceDetails(){
  var model = device.model;
  var deviceID = device.uuid;
  var string = device.version; 

}
}