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

181
Views
next.js getInitialProps no funciona en el navegador móvil

Tengo una aplicación que funciona perfectamente (sin errores) en el escritorio, pero cuando uso **dispositivo móvil**, descubrí que todas las páginas no pueden activar el método getInitialProps en el lado del cliente solo si navego a través del componente Enlace

Este Mi código:

 return( <> <Head> <title> welcome to Anas Behhari | blogging posts for {StaticFunction.Dateit(new Date())} | {new Date().getFullYear() - 1 + "-" + new Date().getFullYear()} </title> </Head> <div className="main"> <div className="container"> <div className="row"> <div className="col-lg-10 offset-lg-1 js-post-list-wrap Blogs-con"> <h2 className="h4 section-title"> <span> Latest posts </span> </h2> {Blogs.map((blog) => ( <Article blog={blog} key={blog._id} /> ))} {BlogList} </div> </div> </div> </div> </> ) blogs.getInitialProps = async (ctx) => { try { const res = await axios.get("http://localhost:3000/api/blogs?offset=0&max=5"); const Blogs = res.data; return { Blogs }; } catch (error) { return { error }; }

};

 export default blogs;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Bueno, después de 2 días de búsqueda en Internet, descubrí que solo necesito cambiar un poco dentro de la función getInitialProps .

El factor principal fue deshacerse de Axios y reemplazarlo con Fetch API

 export async function getStaticProps() { const res = await fetch(`http://localhost:8080/api/blogs}`) const Blogs = await res.json() if(!Tags) return {props:{error:true}} return { props: { Blogs, }, } }

si esta solución no funcionó getServerSideProps en lugar de getStaticProps

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!