본문 바로가기

Project12

5. Query Callback (쿼리콜백) in Node.js 0. Problem app.post('/api/rate', (req,res) => { const {residentName, quality, diff, willing, comment, tags} = req.body; let id = 0; db.query(`SELECT id FROM resident WHERE name = ?;`, [residentName],(err,result)=>{ if(err) throw err; console.log(result); id = result[0].id; }); const query = `INSERT INTO rate(resident_id, quality_rate, difficulty_rate, willingness, comment${tagQueryFront} VALUES .. 2023. 4. 11.
4. Using Variables in useEffect (useEffect에서 변수 쓰기) 03.16.2023 0. Background What I wanted to do was to use the prop as name for components and fetching data from database when props was passed in the result page from the main page. Here is what I did. 1. Store the prop as name using useState function Result(props){ const [name, setName] = useState(null); // Set name using useEffect useEffect(()=>{ if(location.state === null) setName(props.name);.. 2023. 3. 16.
3. Spread Operator (Managing Array State) 2023.03.02 0. Background The reason that made me search for and use it is basically that I wanted to manage a state of an array through useState hook. It didn't work when I tried just updating the array with array functions like this: import {useState} from 'react'; const [tags, setTags] = useState([]); const setTags = (tag) => { setTags(tags.push(tag)); }; const removeTags = () => { setTags(tag.. 2023. 3. 2.
2. Connect Node.js to React.js with Express and Mysql 0. Background Since none of my knowledge has anything to do with backend, I've been searching up how to connect Node.js to React.js for a quite long time.. (maybe being lazy took most of it tho). Anyway, I am making notes of how the connection has been made in this project. 1. Download Downloading is the easiest part. npm install express npm install mysql I wasn't sure cors is required but most .. 2023. 1. 2.
1. How to put props to a page with enter key (엔터키 눌렀을 때 페이지로 인자 넘겨주기) 0. Background I've wanted to implement the function that entering 'enter' key allows main page to switch to result page with a name selected. Before then, Link, provided by react-router-dom, had been used to switch pages. 1. Problem The problem is that Link only enables to pass and receive props through a method of submission, which means that there is no way to interact with props but getting a.. 2022. 12. 31.
0. Motivation / Folder Structure 1. Motivation This project is a solo project that will allow people who lived with me during study abroad program to rate one another. This is motivated by a currently existent website, Rate My Professors (https://www.ratemyprofessors.com/). The aim of this project is to keep in connection among residents from different countries. As it would not be officially used but privately, some functions .. 2022. 12. 24.