Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

can you call api in next.js getserverside props

// pages/home
import { getData } from './api/user'

//...

export async function getServerSideProps(context) {
    const jsonData = await getData()
    //...
}
Comment

can you call api in next.js getserverside props

// pages/home
import { getData } from './api/user'

//...

export async function getServerSideProps(context) {
    const jsonData = await getData()
    //...
}
Comment

can we use getServersideprops in any component in next.js

You cannot use getServerSideProps in non-page components. You can either pass the prop from Home to HomeSection or create a context so the value can be available globally from the component tree

getServerSideProps can only be exported from a page. You can’t export it from non-page files.

https://nextjs.org/docs/basic-features/data-fetching#only-allowed-in-a-page-2
Comment

PREVIOUS NEXT
Code Example
Javascript :: react js nesting 
Javascript :: javascript remove all children with class 
Javascript :: error: cannot find module 
Javascript :: remove # from url javascript 
Javascript :: angular build aot vs jit 
Javascript :: join array of object name javascript 
Javascript :: react native tab.screen hide title 
Javascript :: fadein fadeout jquery 
Javascript :: delay input javascript 
Javascript :: javascript array add front 
Javascript :: basic server on node.js 
Javascript :: dictionary in javascript 
Javascript :: reversed array loop 
Javascript :: vite.config.js 
Javascript :: count number of each element in array javascript 
Javascript :: Reached heap limit Allocation failed - JavaScript heap out of memory nodejs 
Javascript :: window.print a div 
Javascript :: js array add element 
Javascript :: set image size phaser 
Javascript :: javascript random 
Javascript :: nextjs multer rename file 
Javascript :: get object key name in js 
Javascript :: javascript array add 
Javascript :: how to remove spaces from strings javascript 
Javascript :: comprobar si un objeto esta vacio javascript 
Javascript :: async await mongoose connection 
Javascript :: js string times 
Javascript :: react native image auto height 
Javascript :: convert json string or parse 
Javascript :: check to see if work is uppercase javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =