Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

159
Visualizações
What is causing this "Illegal base64 data" error?

I've been working on a project using Next and GraphQL and I am having a hard time figuring out what is causing the following error:

ClientError: GraphQL Error (Code: 400): {"response":{"error":"{\"errors\":[{\"message\":\"parse token failed: illegal base64 data at input byte 0\"}],\"data\":null}","status":400,"headers":{}},"request":{"query":"mutation CreateComment($name: String!, $email: String!, $comment: String!, $slug: String!) {createComment(data: {name: $name, email: $email, comment: $comment, post: { connect: { slug: $slug } } }) { id }}","variables":{"name":"Nate","email":"dasdasd@asasd","comment":"test","slug":"test-slug"}}}

And here is my query. I've tried removing any extraneous spaces and any spelling errors I caught. The token is pulling just fine and everything else seems OK aside from the error:

  console.log(graphcmsToken)
  const { name, email, slug, comment } = req.body;
  const graphQLClient = new  GraphQLClient(graphqlAPI, {
    headers: {
      authorization: `Bearer ${graphcmsToken}`}
  })

  const query = gql`mutation CreateComment($name: String!, $email: String!, $comment: String!, $slug: String!) {createComment(data: {name: $name, email: $email, comment: $comment, post: { connect: { slug: $slug } } }) { id }}`
try {
  const result = await graphQLClient.request(query, req.body)

  return res.status(200).send(result);
} catch (error){
  console.log(error)
  return res.status(500).send(error)
}

Thanks in advance! This has been stumping me for longer than I'd like to admit, and when I try to search around here for an answer I haven't had much luck with JS/Next/GraphQL in particular.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The problem was in the token -- copying and pasting it had added some extra formatting that was causing problems.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda