# JavaScriptでユーザー名またはIDからユーザーオブジェクトを取得する

**URL:** <https://meta.discourse.org/t/get-a-user-object-by-username-or-id-javascript/95342>\
**Category:** Development\
**Created:** [2018 年 8 月 21 日午後 7:03 UTC](https://meta.discourse.org/t/get-a-user-object-by-username-or-id-javascript/95342 "2018-08-21T19:03:43Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [2018 年 8 月 22 日午前 8:19 UTC](https://meta.discourse.org/t/get-a-user-object-by-username-or-id-javascript/95342/2 "2018-08-22T08:19:04Z")

</div>

It is difficult to answer without some more context. You can always do this: (try it in the dev tools for Meta)

```plaintext
Discourse.User.findByUsername("David_Taylor").then(function(user){
   console.log("User Found", user);
});

```

But that will result in an additional request to the server, which may not be necessary.

What are you trying to achieve?

---

_[View the full topic](https://meta.discourse.org/t/get-a-user-object-by-username-or-id-javascript/95342)._
