Skip to content

Commit 693a67c

Browse files
rsill-neo4jmjfwebb
andauthored
Update modules/ROOT/pages/northwind-api.adoc
Co-authored-by: Michael Webb <[email protected]>
1 parent 42aa1fc commit 693a67c

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

modules/ROOT/pages/northwind-api.adoc

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,29 @@ To make it generic, pipe the `contactName` from an input into the query and send
172172

173173
[source, javascript, indent=0]
174174
----
175-
// JavaScript example
175+
async function createCustomer(contactName) {
176+
const mutation = `
177+
mutation CreateCustomer($contactName: String!) {
178+
createCustomers(input: [{ contactName: $contactName }]) {
179+
customers {
180+
contactName
181+
customerID
182+
}
183+
}
184+
}
185+
`;
186+
187+
const res = await fetch(API_URL, {
188+
method: 'POST',
189+
headers: {
190+
'Content-Type': 'application/json',
191+
},
192+
body: JSON.stringify({ query: mutation, variables: { contactName } }),
193+
});
194+
195+
const json = await res.json();
196+
return json;
197+
}
176198
----
177199

178200

0 commit comments

Comments
 (0)