Hi, I’m trying to obtain the topic ID to get the topic and the post ID to get the post from the review page; the review queue’s data-reviewable-id.Is there any way to retrieve the ‘topic ID’ and ‘post ID’ from data-reviewable-id in Javascript? Any help would be appreciated.
1 Like
You can access the reviewable by hitting the /review.json
endpoint:
You can do something like this for example:
import { ajax } from "discourse/lib/ajax";
const reviewableToSearch = 2;
ajax(`/review.json`).then(({ reviewables }) => {
const topicId = reviewables.find((reviewable) => reviewable.id === reviewableToSearch).topic_id;
});
2 Likes
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.