From 33fdcc243efaeeb400e7ba6571ffc593ab5b356c Mon Sep 17 00:00:00 2001 From: Cory Loken Date: Thu, 24 Apr 2025 09:37:46 -0400 Subject: [PATCH] Update handler.js to allow access to MUTATION_OPS This moves mutation ops to a constant outside the object. The original example will result in MUTATION_OPS not found. --- snippets/updating-data/create-record/handler.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/snippets/updating-data/create-record/handler.js b/snippets/updating-data/create-record/handler.js index 56baa52..1b6430c 100644 --- a/snippets/updating-data/create-record/handler.js +++ b/snippets/updating-data/create-record/handler.js @@ -2,9 +2,10 @@ import { recordIdentifierFor } from '@ember-data/store'; import { serializeResources } from '@ember-data/json-api/request'; -const updatesHandler = { - MUTATION_OPS: new Set(['createRecord', 'updateRecord']), +const MUTATION_OPS = new Set(['createRecord', 'updateRecord']); + +const updatesHandler = { request(context, next) { if (!MUTATION_OPS.has(context.request.op)) { // Not a mutation, do nothing