POST body missing. Did you forget use body-parser middleware?
See original GitHub issueI used graphql and koa2.
const Koa = require('koa')
const json = require('koa-json')
const bodyparser = require('koa-bodyparser')
const config = require('./config')
const port = config.URL.port
const cors = require('@koa/cors')
const UserRoute = require('./routes/user.router')
const { ApolloServer, gql } = require('apollo-server-koa')
const app = new Koa()
const typeDefs = gql`
type Book {
title: String
author: String
}
type Query {
books: [Book]
}
`
const resolvers = {
Query: {
books: () => books,
},
}
app.use(cors({
origin: '*',
credentials: true,
methods: ['PUT', 'POST', 'GET', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Content-Length', 'Authorization', 'Accept', 'X-Requested-With', 'x-access-token']
}))
app.use(UserRoute.routes(), UserRoute.allowedMethods())
app.use(bodyparser())
app.use(json())
const server = new ApolloServer({ typeDefs, resolvers })
server.applyMiddleware({
app,
path: config.URL.graphql,
})
module.exports = app.listen(port)
I just want to use graphql on some of the interfaces.
I use postman for debugging. Any good suggestions?
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (6 by maintainers)
Top Results From Across the Web
node.js - GraphQL - POST body missing. Did you forget use ...
I have tried different recommendations with body-parser online, but still can't seem to fix it. Server: require('babel-polyfill') const express ...
Read more >Why I getting this error: POST body missing. Did you forget ...
I am trying to upload a file to the server using apollo-server-fastify. I didn't use the fastify-multipart or similar dependencies because ...
Read more >POST body missing. Did you forget use body-parser ...
Did you forget use body-parser mpoatiddleware? Hi , I already update my katalon to 5.8 , but when I runned my graphQL script...
Read more >post body missing did you forget use body-parser middleware,
We have been having issues with the req.body being empty on POST requests in our middleware, since version 9.0.0. We use this to...
Read more >POST body missing. Did you forget use body-parser ...
Hi,. Has anyone faced this issue. POST body missing. Did you forget use body-parser middleware? SyntaxError: Unexpected token P in JSON at ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Or you can use the package
koa-bodyparser-graphql
directly.ok, thanks for the help