# How to retrieve topic or post id from data-reviewable-id in Javascript?

**URL:** https://meta.discourse.org/t/how-to-retrieve-topic-or-post-id-from-data-reviewable-id-in-javascript/306436
**Category:** Development
**Created:** [May 2, 2024, 6:15am UTC](https://meta.discourse.org/t/how-to-retrieve-topic-or-post-id-from-data-reviewable-id-in-javascript/306436 "2024-05-02T06:15:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![omppatil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omppatil/32/359876_2.png) [@omppatil](https://meta.discourse.org/u/omppatil)
#### Post date: [May 2, 2024, 6:15am UTC](https://meta.discourse.org/t/how-to-retrieve-topic-or-post-id-from-data-reviewable-id-in-javascript/306436/1 "2024-05-02T06:15:19Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![keegan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/keegan/32/383395_2.png) [@keegan](https://meta.discourse.org/u/keegan)
#### Post date: [May 2, 2024, 6:13pm UTC](https://meta.discourse.org/t/how-to-retrieve-topic-or-post-id-from-data-reviewable-id-in-javascript/306436/2 "2024-05-02T18:13:54Z")

</div>

You can access the reviewable by hitting the `/review.json` endpoint:

You can do something like this for example:

```gjs
import { ajax } from "discourse/lib/ajax";

const reviewableToSearch = 2;

ajax(`/review.json`).then(({ reviewables }) => {
  const topicId = reviewables.find((reviewable) => reviewable.id === reviewableToSearch).topic_id;
});

```

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [June 1, 2024, 6:14pm UTC](https://meta.discourse.org/t/how-to-retrieve-topic-or-post-id-from-data-reviewable-id-in-javascript/306436/3 "2024-06-01T18:14:27Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
