Hi guys. I'm getting this error on GraphiQL. `{ "...
# orm-help
w
Hi guys. I'm getting this error on GraphiQL. `{ "data": { "customer": { "first_name": null, "last_name": null, "id": null } } } I'm trying to get the data from a localhost REST API using axios on the resolve. The resolve code looks like: customer: `{ type: CustomerType, args: { id: { type:GraphQLInt } }, resolve (parentValue, {id}) { return axios.get(
127.0.0.1/api/customer/${id}
).then(resp => resp.data); } } }`
j
Console log your response to see what your getting back.
n
@Waweru please share your situation in the Forum: https://www.graph.cool/forum/c/questions
w
Thanks @Jscott388 for the response. Where exactly should I put the console log? const RootQuery = new GraphQLObjectType({ name:'RootQueryType', fields:{ customer:{ type: CustomerType, args: { id: { type:GraphQLInt } }, resolve (parentValue, {id}) { return axios.get(`http://www.slimapp.com/api/customer/${id}`).then(resp => resp.data); } } } })
I've done the console log and found out that the JSON output had square brackets ([ ]) around it. So I've had to get the data[0] to get the data inside the brackets and it has worked. Thanks for you help @Jscott388 😁
j
I figured that what it was