View parse.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//at services/parse.js | |
import Parse from 'parse'; | |
//checking if env is browser | |
if (typeof window !== "undefined") { | |
Parse.initialize("APP_ID","JS_KEY"); | |
Parse.serverURL = 'https://parseapi.back4app.com/'; | |
} |
View parse.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Parse from 'parse'; | |
if (typeof window !== "undefined") { | |
Parse.initialize(process.env.PARSE_APP_ID,process.env.PARSE_JS_KEY); | |
Parse.serverURL = 'https://parseapi.back4app.com/'; | |
} | |
export default Parse; |
View index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react"; | |
import styles from "../styles/Home.module.css"; | |
import Parse from "../service/parse"; | |
export default function Home() { | |
const [employeeName, setEmployeeName] = useState(""); | |
const [employeeEmail, setEmployeeEmail] = useState(""); | |
const [employeePassword, setEmployeePassword] = useState(""); | |
const [employees, setEmployees] = useState([]); |
View parseUserExample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const employee = new Parse.Object('Employee'); | |
employee | |
.save({ | |
username: employeeName, | |
email: employeeEmail, | |
password: employeePassword, | |
}) |
View getUsersFunctionExample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getEmployees = async () => { | |
const query = new Parse.Query("Employee"); | |
const res = await query.findAll(); | |
const employees = res.map((employee) => ({ name: employee.get("username") })); | |
setEmployees(employees); | |
}; |
View _app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "../styles/globals.css"; | |
import { initializeParse } from "@parse/react-ssr"; | |
initializeParse( | |
"https://parsechatarticletest.b4a.io/", | |
"PARSE_APP_ID", //Insert your parse app id here | |
"PARSE_JS_KEY", //Insert your parse JS key | |
); | |
function MyApp({ Component, pageProps }) { |
View pages_index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react"; | |
import styles from "../styles/Auth.module.css"; | |
export default function Auth() { | |
const [isRegistering, setIsRegistering] = useState(false); | |
const [username, setUserName] = useState(false); | |
const [password, setPassword] = useState(false); | |
const toggleIsRegistering = () => setIsRegistering(!isRegistering); |
View handleRegister.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const handleRegister = () => { | |
const user = new Parse.User(); | |
user | |
.save({ | |
username, | |
password, | |
}) | |
.then(() => { | |
handleLogin(); |
View handleLogin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const handleLogin = () => { | |
Parse.User.logIn(username, password).then((user) => { | |
console.log(`successfully loged ${user.get("username")}`) | |
}); | |
}; |
View index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function Home() { | |
const router = useRouter(); | |
//..rest of the code |
OlderNewer