I used a jQuery storage to store data.
oStore = jQuery.sap.storage(jQuery.sap.storage.Type.local);
oStore.put("id", rep);
but I am getting this error:
Cannot read property 'Type' of undefined
Can you please help?
The module sap/ui/util/Storage, which is available since UI5 1.58, replaces jQuery.sap.storage.
sap.ui.define([
"sap/ui/util/Storage",
// ...
], function(Storage/*,...*/) {
"use strict";
const storageType = Storage.Type.local;
const storage = new Storage(storageType);
// ...
});
API reference: sap/ui/util/Storage
The reason, why jQuery.sap.storage is not defined, is that the module has not yet been loaded (and thus not globally accessible). Whenever you're using jQuery APIs, make sure to resolve its dependency first, and then use the resolved parameter name instead of accessing APIs globally as mentioned in the documentation:
Use only local variables inside the AMD factory function, do not access the content of other modules via their global names, not even for such fundamental stuff like
jQueryorsap.ui.Device. You can't be sure that the modules are already loaded and the namespace is available.
Example:
sap.ui.define([
"jquery.sap.storage",
// ...
], function(jQuery/*,...*/) {
"use strict";
const storageType = jQuery.sap.storage.Type.local;
const storage = jQuery.sap.storage(storageType);
// ...
});

API reference: jquery.sap.storage
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With