JavaScript client 422 Unprocessable Entity error

Hi all,

I’ve encountered an error fetching custom post with JavaScript API client. My function to browse all posts works well, but with{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 =
                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:

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

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?

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

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 !