-
Notifications
You must be signed in to change notification settings - Fork 74
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
日報個別ページにその人の直近数個の日報を表示する(Vue.jsで) #3118
Conversation
21fc434
to
4ed833f
Compare
@machida |
了解ですー |
@harukus 2カラムにしましたー |
@machida ありがとうございます! |
.then((response) => { | ||
return response.json() | ||
}) | ||
.then((json) => { | ||
this.reports = [] | ||
json.reports.forEach((r) => { | ||
this.reports.push(r) | ||
}) | ||
this.currentUserId = json.currentUserId | ||
}) |
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.
JavaScriptはあまり詳しくないので、コードを読んで気になった点を質問させてください!
- なぜ
then
を2回使っているのか forEach
,push
を使っている理由
.then((response) => { | |
return response.json() | |
}) | |
.then((json) => { | |
this.reports = [] | |
json.reports.forEach((r) => { | |
this.reports.push(r) | |
}) | |
this.currentUserId = json.currentUserId | |
}) | |
.then((response) => { | |
const json = response.json() | |
this.reports = json.reports | |
this.currentUserId = json.currentUserId | |
}) |
then
を1つにして、 reports
もそのまま代入できそうかなと思ったので。
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.
@sinsoku
返信が遅くなって申し訳ありません。
- なぜ then を2回使っているのか
説明が合っているかわからないのですが、fetchメソッドはPromiseを返し、PromiseはResponseオブジェクトとして解決されるためです。 - forEach, push を使っている理由
こちらは参考にしたPRのコードをそのまま真似したため、簡潔に書きなおしました。
確認お願いいたします。
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.
@harukus
thenは1つにしても動きそうかなと思ったのですが、これだと動かなくなったりするでしょうか?
.then((response) => {
const json = response.json()
this.reports = json.reports
this.currentUserId = json.currentUserId
})
コードが短くなるので、動くなら短いコードの方が良いなと思いました!
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.
@sinsoku
上記のコードでは直近の日報が表示されなくなってしまいました><
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.
あれ、動かないのか。
それなら今のコードのままで良さそうです!
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.
@sinsoku
ありがとうございます!
1da046c
to
e63e510
Compare
@machida ちょっとこのブランチの日報個別ページのslimが最新と差分が大き過ぎてコンフリクト修正時に間違ってしまったかもです。デザインがずれてしまったのですがちょっと確認してもらってよいでしょうか、すみません。 |
e63e510
to
277efef
Compare
@komagata デザイン調整を行いましたー 見た目はこれで大丈夫なのですが、routes のコンフリクトを解消したのでコードの方のご確認お願いします🙏 直近の日報は全ユーザーが見れるようにしました。 |
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.
確認しました、OKですー🙆♂️
@machida 修正ありがとうございます! |
277efef
to
e2d7a1d
Compare
@komagata テスト通しましたー |
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.
確認しました、OKですー🙆♂️
issue
#2649
(#2660 の作り直し)
#3130
やったこと
提出物での表示
日報での表示