我需要重写此方法:normalize(payload,modelName)
在ember-cli-mirage插件和序列化器注册表文件中
https://github.com/samselikoff/ember-cli-mirage/blob/master/addon/serializer-registry.js#L21
我不知道在我的ember项目中将文件放在哪里覆盖它。
您是否需要为所有序列化程序或仅对一个序列化程序覆盖它?
如果有的话,您可以在应用程序序列化器上进行如下操作:
// mirage/serializers/application.js
import { JSONAPISerializer } from 'ember-cli-mirage';
export default JSONAPISerializer.extend({
normalize(payload, modelName) {
// This is how to call "super"
let jsonApiDocument = JSONAPISerializer.prototype.serialize.apply(this, arguments);
// Tweak the document
return jsonApiDocument;
}
});
请注意,normalize()
仅由POST和PUT速记使用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句