-
Notifications
You must be signed in to change notification settings - Fork 0
Week18 完成 #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Week18 完成 #20
Conversation
| app.use(bodyParser.urlencoded({ extended: false })) | ||
| app.use(bodyParser.json()) | ||
| app.use(session({ | ||
| secret: 'keyboard cat', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這個應該放在環境變數才對,如同 secret 字面上的意思
| req.flash('errorMessage', '更新文章失敗') | ||
| return res.redirect(`/update/${ArticleId}`) | ||
| }) | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以稍微排版一下,比如說
handleUpdateArticle = (req, res) => {
const ArticleId = req.params.id
const { title, TagId, content } = req.body
if (!title || !TagId || !content) {
req.flash('errorMessage', '請填入所有欄位')
return res.redirect(`/update/${ArticleId}`)
}
Article.update(
{
title,
TagId,
content,
},
{ where: { id: ArticleId } }
)
.then((newArticle) => {
res.redirect('/blog')
})
.catch((error) => {
console.log(error)
req.flash('errorMessage', '更新文章失敗')
return res.redirect(`/update/${ArticleId}`)
})
}| down: async (queryInterface, Sequelize) => { | ||
| return queryInterface.bulkDelete('Users', null, {}); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這個檔案是不是不小心上傳了 XD
| down: async (queryInterface, Sequelize) => { | ||
| return queryInterface.bulkDelete('Users', null, {}); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這個也是
| "host": "127.0.0.1", | ||
| "dialect": "mysql" | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這個檔案要加進 .gitignore 才對
| }) | ||
| }, | ||
|
|
||
| get: (req, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
命名可以更清楚一點,比如說 getArticle,這一部分可以參考其他同學的命名
|
這邊沒有部落格作業的連結,再麻煩同學提供了 :) 目前整體看下來,大部分同學犯的錯誤,同學這邊都沒有犯,但就是一些關鍵檔案不小心上傳上來了,這邊不可不慎 |
餐廳網站
餐廳網站連結
餐廳網站後台
帳號 / 密碼:admin / adminhw2
完成餐廳網站 menu 功能,但是因為上傳圖片研究不出來,所以只能上傳圖片網址。
hw3
完成 FAQ 後台