im working on shopify project to develop the android app. Currently im facing issue when creating customer. im tried to solve it if someone know about this please help me out!
Create customer mutation query
const query= `mutation customerCreate($input: CustomerCreateInput!) {
customerCreate(input: $input) {
customer {
acceptsMarketing
email
firstName
lastName
password
phone
}
customerUserErrors {
field
message
code
}
variables: {
"input": {
"acceptsMarketing": true,
"email": "[email protected]",
"firstName": "John",
"lastName": "Smith",
"password": "5hopify",
"phone": "111111111111"
}
},
}
}`;
async function apiCall(query) {
return fetch('https://storename.myshopify.com/api/graphql.json', {
method: 'POST',
headers: {
'Content-Type': 'application/graphql',
'Access-Control-Origin': '*',
'X-Shopify-Storefront-Access-Token': token,
},
body: query,
})
.then(response => response.json())
.then(response => console.log('response: ', response))
.catch(error => console.log('error: ', error.message));
}
facing the below error
{"errors": [{"locations": [Array], "message": "Parse error on "{" (LCURLY) at [16, 20]"}]}
2
Answers
Use the following query. its worked for me
The error is telling you there’s a parse* error on line 16 column 20. Parse errors usually point to typos, and my best guess is the
:
you have aftervariables
on line 16 – is that symbol supposed to be there?