import axios from 'axios'; import Router from 'next/router'; import React, { useEffect } from 'react' import useSWR from 'swr' const Users = (props) => { const address = `/api/users`; const fetcher = async (address) => await axios.get(address).then(async (res)=>await res.data); const {data, error} = useSWR(address, fetcher, { refreshInterval: 1000 }); if(error){ console.log('error in finding data'); } const deletePost = async postID => { await fetch(`/api/DeleteUser?id=${postID}`, { method: "DELETE", headers: {"Content-Type": "application/json"} }); // await Router.reload() } useEffect((postID)=>{ deletePost(postID) }, []) return ( <>
{item?.name}
{item?.email}
{item?.details?.map((item, index)=>{ return( <>
{item?.unique_id}
{item?.module_version}
{item?.language}
> ) })}