Questions tagged [getstaticprops]
90 questions
0
votes
0 answers
Data fetching without SWR
When it comes to fetching data i usually use SWR because it's easy-to-use package, but this time i wanted to fetch data using getServerSideProps or getStaticProps, And of course i tried to use SWR inside them.
But as you know, you can't use it…

joehsn
- 21
- 2
0
votes
0 answers
Properties "missing" from type definitions for schemas for Sanity
I'm using Sanity in a project and came across an error when I tried to pass props to a component
that says: "Type 'Card[]' is missing the following properties from type 'Card': _type, title, image, description, and 4 more." Card in this context is…

Diandre402
- 64
- 4
0
votes
0 answers
Generate paginated URLs like ?page=2, ?page=3 etc. in NextJS getStaticPaths and access the query params in getStaticProps
I am building a NextJS based site with multiple locales (different domains) where the data comes from storyblok CMS (folder level translation).
I am trying to figure out the best approach to statically generate the paginated URLs for the blog and…

mrued
- 1
- 1
0
votes
1 answer
Next.js getStaticProps params in context equal '[object Object]' / getStaticProps gets called multiple times
I am trying to understand why getStaticProps is getting called multiple times.
The relevant file is called [postId].js in my pages/posts folder; code below:
const MyPost({post}) => {
// Main component in here
}
export default MyPost
export async…

Fesch
- 313
- 1
- 4
- 12
0
votes
0 answers
How do I render props for React Bootstrap Icons
I am running into a slight problem when trying to render a React Bootstrap Icon in Next.js.
I am using getStaticProps to make a call to the Notion API, to then use as props in my page, and everything is working fine.
However, I would like to define…

kilnerbank
- 19
- 4
0
votes
1 answer
How can I get data with getStaticProps in Next.js
I have datas from getStaticProps. Bu I have problem when I get data inside function. I don't know how can I get.
export async function getStaticProps(){
const res = await axios.get(`https://dummyjson.com/products?limit=10&skip=${page*10-10}`)
…
0
votes
0 answers
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
I am quite new in coding and I am struggling with deploying on Vercel. Let me show you whats the problem:
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: fetch failed
at Object.fetch…

elpatryk
- 1
0
votes
1 answer
Cannot fetch strapi data when using next.js getStaticProps
I'm trying to display content from strapi on a next.js app which is statically generated.
I run both strapi & next.js on localhost (strapi on localhost:1337, next.js on localhost:4200) and I have disabled cors on strapi.
{
name:…

caisah
- 1,959
- 1
- 21
- 31
0
votes
1 answer
Next.js getStaticProps passing data as object
I am new to working with typescript and next.js. I am using Vercel to deploy a Next.js webapp that will pull data from a heroku postgresSQL db using Prisma. I am trying to render some data on the page using observable/d3, using getStaticProps to…

Alejandro Zapien
- 63
- 1
- 9
0
votes
0 answers
How to convert our local images to Base64 in Next js using Plaiceholder
I have been using plaiceholder for getting base64 converted image to pass in blurDataUrl in next/Image component.
export const getStaticProps = async () => {
const { base64, img } = await getPlaiceholder(
"imagePath",
{ size: 10…

Muskan Rawal
- 58
- 1
- 9
0
votes
1 answer
how to change api calls when dropdown values changes nextjs
I am working on a nextjs project that is a calendar. when country and year changes calendar should change and I use a holidays API. API url contains country and year parameters(https://localhost:5001//holiday?&country=${country}&year=${year}). SO I…

hanu
- 53
- 1
- 10
0
votes
0 answers
getStaticProps did't return data
I am trying to fetch data from Storyblok API, but in getStaticProps I get the data from the storybook but it can't return data to the page.
pages/docs/[slug].js
import React from 'react'
import Storyblok from "../../lib/storyblok"
export default…

WStar
- 187
- 2
- 12
0
votes
1 answer
Handle errors of API call in getStaticProps in NextJS
I have multiple API calls in the getStaticProps. I want handle errors for each API call individually. How can I do that?
export async function getStaticProps(context) {
const fund = context.params.fund;
const avggReturnsRes = await fetch(
…

PRASANTH BATTULA
- 47
- 1
- 8
0
votes
1 answer
getStaticProps Does not return any data to the pages on Next.JS
I'm trying to fetch a data from my hosted database. The database itself are working (I have checked it from the swagger app) but no data is shown when it is called from API form.
import React from 'react';
export const getStaticPaths = async () =>…

Friel
- 51
- 4
0
votes
1 answer
How do i create a conditional loading message in react
I have a react code here
i want to load data from an API but it's taking time to get the data, thus my function is failing
How do i set it that it should wait for the data before rendering
import Head from 'next/head'
import Link from…

Micky
- 15
- 1
- 5