Fixes minor axios/useState issue

This commit is contained in:
Jyotirmoy Bandyopadhayaya 2022-03-10 21:59:45 +05:30
parent 5657bf0641
commit 705c3c5c8d
4 changed files with 1129 additions and 1079 deletions

View File

@ -1,2 +1,2 @@
NODE_ENV=dev NODE_ENV=dev
NEXT_PUBLIC_API_URL=http://localhost:5000 NEXT_PUBLIC_API_URL=https://api.minfy.xyz

View File

@ -1,30 +1,32 @@
import UserAuth from "./usercontext" import UserAuth from './usercontext'
import { useState } from 'react' import { useState } from 'react'
import axios from "axios" import axios from 'helpers/Axios'
const UserAuthProvider = ({ children }) => { const UserAuthProvider = ({ children }) => {
const [user, setUser] = useState(null) const [user, setUser] = useState(null)
const login = () => { const login = () => {
setUser('default') setUser('default')
} }
const createAcc = (data) => { const createAcc = (data) => {
axios.post('http://localhost:5000/user/register/', { axios
email: data.email, .post(`/user/register`, {
password: data.password, email: data.email,
}) password: data.password,
.then(function (response) { name: data.name,
console.log(response); })
}) .then(function (response) {
.catch(function (error) { console.log(response)
console.log(error); })
}); .catch(function (error) {
} console.log(error)
})
}
const logout = () => { const logout = () => {
setUser(null) setUser(null)
} }
const context = { user, login, logout, createAcc } const context = { user, login, logout, createAcc }
return <UserAuth.Provider value={context}>{children}</UserAuth.Provider> return <UserAuth.Provider value={context}>{children}</UserAuth.Provider>
} }
export default UserAuthProvider; export default UserAuthProvider

View File

@ -46,7 +46,7 @@ Redirector.getInitialProps = async (context) => {
if (context?.res) { if (context?.res) {
const go = resData?.data?.originalUrl ? resData?.data?.originalUrl : '/404' const go = resData?.data?.originalUrl ? resData?.data?.originalUrl : '/404'
console.log(go) // console.log(go)
context?.res.writeHead(302, { context?.res.writeHead(302, {
Location: go, Location: go,
}) })

File diff suppressed because it is too large Load Diff