Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
TypeError: no se pueden leer las propiedades de undefined (leyendo 'documento')

Estaba usando qraphql (biblioteca de JavaScript graphql-request) en un proyecto y me encontré con un typeError. Aquí está el código:

 import { request, gql } from 'graphql-request' const graphqlAPI = process.env.NEXT_PUBLIC_GRAPHCMS_ENDPOINT export const getPosts = async () => { const query = gql` query MyQuery { postsConnection { edges { node { author { bio name id photo { url } } createdAt slug title excerpt featuredImage { url } categories { name slug } } } } } ` const result = await request(graphqlAPI, query) return result.postsConnection.edges }

El error decía que había un problema con el parámetro del documento de la solicitud.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

2 errores:

  1. El método que ha utilizado aquí para obtener los datos está desactualizado.
  2. Falta el punto final aquí, lo encontrará en los gráficos de su cuenta: configuración/acceso/acceso a la API/puntos finales

Quitar el comando

 const graphqlAPI = process.env.NEXT_PUBLIC_GRAPHCMS_ENDPOINT

y el archivo .env asociado a él. Después de eso usa el siguiente código:

 import { gql } from 'graphql-request'; import { GraphQLClient } from 'graphql-request'; export const getPosts = async () => { // new endpoint const graphQLClient = new GraphQLClient( endpoint // here add your endpoint ); const query = gql` query MyQuery { postsConnection { edges { node { author { bio name id photo { url } } createdAt slug title excerpt featuredImage { url } categories { name slug } } } } } ` const result = await graphQLClient.request(query) return result.PostsConnection; }
about 4 years ago · Juan Pablo Isaza Report

0

No importa, es porque el Next_endpoint no estaba definido, ¡todo bien ahora!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!