-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[GitHubReleaseDate] - published_at field #8543
[GitHubReleaseDate] - published_at field #8543
Conversation
|
if (Array.isArray(body)) { | ||
if (queryParams.display_date === 'published_at') { | ||
return this.constructor.render({ date: body[0].published_at }) | ||
} | ||
|
||
return this.constructor.render({ date: body[0].created_at }) | ||
} | ||
|
||
if (queryParams.display_date === 'published_at') { | ||
return this.constructor.render({ date: body.published_at }) | ||
} | ||
|
||
return this.constructor.render({ date: body.created_at }) | ||
} |
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.
In javascript you can address an object property defined by a variable using square brackets, so you should be able to reduce all this to just
if (Array.isArray(body)) {
return this.constructor.render({ date: body[0][queryParams.display_date] })
}
return this.constructor.render({ date: body[queryParams.display_date] })
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.
Neat, thanks. Updated.
closes #6309
For the GitHub Release Date badge by default we still use the
created_at
field.Now, if the user gives the
display_date=published_at
query param, that field from the API response would be used.https://api.github.com/repos/microsoft/vscode/releases/latest
http://localhost:8080/github/release-date/microsoft/vscode
http://localhost:8080/github/release-date/microsoft/vscode?display_date=published_at