我需要重写这个方法: normalize(payload,modelName)
在ember-cli- file插件和序列化程序注册表文件中
https://github.com/samselikoff/ember-cli-mirage/blob/master/addon/serializer-registry.js#L21
我不知道在我的ember项目中把文件放在哪里来覆盖它。
发布于 2019-03-08 04:07:28
您需要覆盖所有序列化程序还是只覆盖一个序列化程序?
如果是这样的话,你可以在应用程序序列化程序上这样做:
// 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速记使用。
https://stackoverflow.com/questions/55040499
复制相似问题