Rafi
Rafi

Reputation: 33

Pass NameSpace to object and save to localstorage

Hello I have an android application that opens up the device certificates and get some information back from it (APPCID).

  handleCeritifcate(appid) {
OData.defaultHttpClient = sap.AuthProxy.generateODataHttpClient();
this.factory.connectionData = { DeviceType: "Android" };
this.factory.clientCert = new sap.AuthProxy.CertificateFromStore();

console.log("app clientcert:", this.factory.clientCert);


var sUrl = this.factory.baseUrl + "/odata/applications/latest/" + appid + "/Connections";

var request = {
  headers: {},
  certificateSource: this.factory.clientCert,
  requestUri: sUrl,
  data: this.factory.connectionData,
  method: "POST"
};


OData.request(request, (result => {
  // this.onSuccessForRegister(result);
  console.log("certificate success:", result);

}), (error) => {
  console.log("ceritficate error", error);
});

}

enter image description here

I want to save the value I get from this.factory.clientCert and save to localstorage so I can pass it to another app , I'm using inappbrowser postmessage to pass data between sites. But when I try to save clientCert, it only saves the JSON inside it:

{ SYSTEM : SOURCE } 

without the AuthProxy.CertificateFromStore.

Help would be greatly appreciated.

Upvotes: 0

Views: 42

Answers (1)

tom
tom

Reputation: 10529

You are trying to store an instated object into the localstorage.

You can try to convert the instance with JSON.stringify() (MDN) and then save that.

localStorage.setItem(clientCert, JSON.stringify(this.factory.clientCert));

console.log(JSON.parse(localStorage.getItem("clientCert"));

Upvotes: 1

Related Questions