-
DummyJSON
DummyJSON.com provides different types of REST Endpoints filled with JSON data which you can use in developing the frontend with your favorite framework and library without worrying about writing a backend.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
Preview: https://next-auth-example-mu-two.vercel.app/ Repo: https://github.com/rafaelmagalhaes/next-auth-example
import { NextPage } from 'next' import { useState } from 'react' import { setCookie } from 'cookies-next' import { useRouter } from 'next/router' import { useAuthStore } from '~/store/useAuthStore' // import our useAuthStore const SignIn: NextPage = (props) => { // set UserInfo state with inital values const [userInfo] = useState({ email: 'kminchelle', password: '0lelplR' }) const router = useRouter() // import state from AuthStore const setUser = useAuthStore((state) => state.setUser) const setAuthentication = useAuthStore((state) => state.setAuthentication) const login = async () => { // do a post call to the auth endpoint const res = await fetch('https://dummyjson.com/auth/login', { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username: userInfo.email, password: userInfo.password, }), }) // check if response was ok if (!res.ok) { return console.error(res) } // retrieve data from the response const data = await res.json() // check if we have data if (data) { setUser(data) // set data to our user state setAuthentication(true) // set our authentication state to true setCookie('token', data?.token) // set token to the cookie router.push('/') // redirect to home page } } return (
) } export default SignInLogin
Username (userInfo.email = event.target.value)} required /> Password (userInfo.password = event.target.value)} name="psw" required /> Login
Related posts
-
Next Auth boilerplate TS
-
Integrating GraphQL Codegen + React Query + Clerk JWT Tokens
-
UI for fake REST API challenge. How would you rate my skills?
-
What are some of the simplest web applications and/or API's out there that are popular
-
Spacetraders is an online multiplayer game based entirely on APIs. You have to build your own management and UI on your own with any programming language.