Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const Class = getClass(context);
let settings = await Class.load();
if (!settings) {
settings = new Class();
}
if (!settings.data) {
settings.data = {};
}
try {
settings.data.populate(data);
await settings.save();
return settings;
} catch (e) {
return new ErrorResponse(e);
}
};