That’s a promise. Are you returning it right?
let res = await results.json();
But I think it would be better to do something like:
fetch('localhost:8080/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/graphql',
},
body: `mutation {
addUser(input: {name: "pp", created_at: "2019", username: "as", password: "afsafasf"}) {
numUids
}
`
})
.then((res) => res.json())
.then((result) => console.log(result));
I would create a function for this too. To not be repetitive.