I am trying to use graphql through apollo-client. On frontend there is Ember, on backend we have django and graphql server, implemented on this tutorial (https://www.howtographql.com/graphql-python/0-introduction/). The Ember application is on 4200 port, the graphql server is proxied on 8000/graphql (ember s --proxy http://localhost:8000)
I tried to follow this guide (https://www.howtographql.com/ember-apollo/1-getting-started/), but without graphcool, because we have backend.
In a controller signup.js I have
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import Mutation from '../gql/mutation';
I have injected apollo this way
export default Controller.extend({
apollo: Ember.inject.service(),
And the mutation is this
actions: {
signUp() {
let username = this.get('username');
let password = this.get('password');
let email = this.get('email');
const credentials = { username, password, email };
let mutation = Mutation.CREATE_USER;
return this.get('apollo').mutate({mutation, credentials}, 'createUser').then(() => {
this.set('username', '');
this.set('email', '');
this.set('password', '');
console.log('user created successfully!');
}).catch(error => console.log('ERROR!!!!111:', error));
After clicking submit button in a form, I got this message
POST http://localhost:4200/graphql 500 (Internal Server Error)
ServerParseError: Unexpected token < in JSON at position 0
What can I do?
Aucun commentaire:
Enregistrer un commentaire