# JavaScript client 422 Unprocessable Entity error

**URL:** <https://forum.ghost.org/t/javascript-client-422-unprocessable-entity-error/21929>\
**Category:** Developer help\
**Created:** [April 15, 2021, 5:56pm UTC](https://forum.ghost.org/t/javascript-client-422-unprocessable-entity-error/21929 "2021-04-15T17:56:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vlntsolo](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vlntsolo/32/12718_2.png) [@vlntsolo](https://forum.ghost.org/u/vlntsolo)\
**Post date:** [April 15, 2021, 5:56pm UTC](https://forum.ghost.org/t/javascript-client-422-unprocessable-entity-error/21929/1 "2021-04-15T17:56:26Z")

</div>

Hi all,

I’ve encountered an error fetching custom post with JavaScript API client. My function to browse all posts works well, but with `api.posts.read({slug: 'welcome'});` appears to be an issue.  
Console givers: GET 422 (Unprocessable Entity)

This is how the call looks like:

```
export async function fetchArticle(slug) {

        const promise = api.posts.read(
            {
                slug: slug
            },
            {
                formats: ['html', 'plaintext']
            }
        )
        return await promise
};

```

And loading the page with slug “welcome” this is what I get in the console GET / XHR error:  
[http://localhost:2368/ghost/api/v3/content/posts/?key=b78272c3dcdc852b126455c4b7&fields=id%2C%20title%2Ccustom\_excerpt%2Cfeatured%2Cfeature\_image%2Cslug%2Curl%2Cpublished\_at&include=tags&page=welcome](http://localhost:2368/ghost/api/v3/content/posts/?key=b78272c3dcdc852b126455c4b7&fields=id%2C%20title%2Ccustom_excerpt%2Cfeatured%2Cfeature_image%2Cslug%2Curl%2Cpublished_at&include=tags&page=welcome)

I tried to use **id** instead of **slug** , but the key each time goes to the `page= `

Ghost v. 4.2.1 (dev/local)  
Node v. 14.16.1

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kevin/32/32_2.png) [@Kevin](https://forum.ghost.org/u/Kevin)\
**Post date:** [April 15, 2021, 6:00pm UTC](https://forum.ghost.org/t/javascript-client-422-unprocessable-entity-error/21929/2 "2021-04-15T18:00:39Z")

</div>

The URL that you’ve posted doesn’t match up with the shared code. Have you reduced the code provided to remove the `fields` and `include` param?

---

<div class="post-metadata">

**Author:** ![vlntsolo](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vlntsolo/32/12718_2.png) [@vlntsolo](https://forum.ghost.org/u/vlntsolo)\
**Post date:** [April 15, 2021, 6:04pm UTC](https://forum.ghost.org/t/javascript-client-422-unprocessable-entity-error/21929/3 "2021-04-15T18:04:16Z")

</div>

Nope, that’s exactly what I’m using to get the post data. The URL with query really looks weird.

---

<div class="post-metadata">

**Author:** ![vlntsolo](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vlntsolo/32/12718_2.png) [@vlntsolo](https://forum.ghost.org/u/vlntsolo)\
**Post date:** [April 15, 2021, 6:12pm UTC](https://forum.ghost.org/t/javascript-client-422-unprocessable-entity-error/21929/4 "2021-04-15T18:12:52Z")

</div>

Omg, sorry for bringing it up. I’ve messed with the external module. Just moved this function to a separate file and the call worked! It appears to be the call to fetch all posts above with `export default` affected the import.

Lack of experience with JS. Thanks for the hint @Kevin !
