nodejs 6

<nodejs>내가 모르는 것들 정리

nodejs를 배우면서 내가 까먹거나 모르는 개념, 아주 기초적인 거라도 정리하자 ! const profile = { name:"쥬쥬", age:25, school:"쥬라기대학교", age:27 } console.log(profile.age) → 콘솔에 27 출력 (밑에있는 age가 위의 age를 덮어 씀) class ProductController { productService; constructor(private readonly productService){ this.productService = productService; } buyProduct(req,res){ this.productService.qqq(); }; } public, private, protected, readonly 중 1개라도 ..

nodejs 2023.11.02

rest client 사용하기

오늘 배운 것 ? rest client로 Api 요청 하기 Rest Client 는 API를 조회하기 위한 VSCode의 확장 프로그램이다 사용하기 위해서는 1. vscode에서 rest client를 설치한다 2. [name].http파일을 생성한다 해당 파일에 crud테스트 코드를 작성하면 되는데 get,post,put ......다 가능하다 다만, 각 요청을 할때는 ### 로 구분해주어야 한다 !! 예를들어, GET http://localhost:3000/person ### POST http://localhost:3000/person Content-Type: application/json { "name": "anygg", "age": 25, "email": "a22@dddd.com" } GET요청을..

nodejs 2023.10.25

node.js에서 map() 사용 할 때

먼저 map()함수란?? 배열을 처리해서 새로운 배열로 반환하기 위한 함수라고 한다. map()함수는 배열을 순회하며 지정된 콜백함수를 적용하여 각 요소를 변환하고, 그 변환된 값을 모아서 새로운 배열로 반환하는 역할을 한다고 한다 .... 개념은 어렵고, 여러 페이지에 나와있는 예시는 이해가 갔는데 내가 실습한 코드는 조금 이해가 안가서 일단 적어두고 나중에 다시 검토해보기 ! .then((data) => { if (!data.articleList || data.articleList.size === 0) { throw new Error("데이터가 없습니다."); } return data.articleList; }) .then((articles) => { return articles.map((articl..

nodejs 2023.10.24

javascript에서 filter() 사용방법

배열에서 특정 요소를 삭제하고 싶을때, 다르게 말하면 특정 요소를 삭제하고, 나머지 애들을 할당시켜주고 싶을때, filter()를 쓴다고한다. app.post("/posts", (req, res) => { const { title, name, text } = req.body; posts.push({ id: posts.length + 1, title, name, text, createdDt: Date() }); res.json({ title, name, text }); }); app.delete("posts/:id", (req, res) => { const id = req.params.id; const filteredPosts = posts.filter((post) => post.id !== +id); c..

nodejs 2023.10.24

Javascript에서 함수선언식(function ..(){})을 사용했을때와 화살표함수(const .. = () =>{})를 사용했을때의 차이점

책으로 express로 연습을 하고 있는데 강의들을때는 이해하지 못했던 개념이 이해가 돼서 조금씩 작성해 놓는다 ! app.get("/", function (_, res) { res.end("HOME"); }); app.get("/user", user); app.get("/feed", feed); app.listen(3000, () => { console.log("익스프레스로 라우터 리팩터링하기"); }); const user = (req, res) => { const userInfo = url.parse(req.url, true).query; res.json(`[user]name: ${userInfo.name}, age:${userInfo.age}`); } const feed = (_, res) => ..

nodejs 2023.10.24

부트스트랩으로 쉽게 css 적용하기

1. 부트스트랩에 접속한다 2. 부트스트랩의 introduction에 들어간다 3. 만약 내가 이미 만들어 놓은 html문서가 있다면 1번은 제치고 2번을 참고하여 2번의 link태그와 script태그의 내용을 복사하고 내 html문서에 붙여넣기한다. link태그는 head태그안에 script태그는 body태그가 닫히기 전에 넣어준다. 그럼 설정 끝 !! 4.이제 내가 바꿔주고 싶은 태그 alert라던가 button이나 등등... h1스타일이나 무엇이든지 부트스트랩 홈페이지에서 원하는 스타일을 골라서 바꿔주고 싶은 태그에 class 지정해주면 끝 5. 버튼 태그를 꾸며주고 싶으면 부트스트랩 docs의 buttons으로 들어가서 내가 하고 싶은 스타일을 복사해가지고 오면된다 ! 예를들어, 나는 버튼을 노란..

nodejs 2023.10.23