NextJS_DOC/pages/Components/Prisma/CreateUser.js

50 lines
1.2 KiB
JavaScript

import prisma from '@/lib/Prisma';
import React from 'react'
import useSWR from 'swr'
function CreateUser(props){
const data = props?.feed;
const [userinfo, setUserInfo] = React.useState();
const token = userinfo?.map((item)=>{
return item?.token;
})
// console.log(token);
const details = userinfo?.map((item)=>{
return item?.details;
})
const language = details?.map((item, index)=>{
return item[index]?.language;
})
// console.log(language);
const module_version = details?.map((item, index)=>{
return item[index]?.module_version;
})
// console.log(module_version);
React.useEffect(()=>{
setUserInfo(data)
},[])
return (
<>
{token && <p>Token : {token}</p>}
{language && <p>Language : {language}</p>}
{module_version && <p>Module_Version : {module_version}</p>}
</>
)
}
export const getStaticProps = async () => {
// Fetch data from external API
const feed = await prisma.users.findMany({
select: {
token: true,
details: true
}
})
// Pass data to the page via props
return {
props: { feed },
// revalidate: 10,
}
}
export default CreateUser