# Not receiving image url's in Fetch request of all Post

**URL:** <https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918>\
**Category:** JS SDK\
**Created:** [September 13, 2023, 8:58am UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918 "2023-09-13T08:58:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashish](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Ashish](https://forum.social.plus/u/Ashish)\
**Post date:** [September 13, 2023, 8:58am UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/1 "2023-09-13T08:58:20Z")

</div>

Hey,  
I am trying to fetch the Global post of the user using the function below.

```auto
    const queryParams = {
      targetType: "global",
      sortBy: "lastCreated",
      includeDeletedPosts: true,
      limit: query.pageSize ?? 20,
    };
      const liveCollection = await PostRepository.queryPosts(queryParams);

      let response = await new Promise((resolve) => {
        liveCollection.on("dataUpdated", (posts) => {
          resolve(posts);
        });
      });

```

However, I am not receiving Image URLs of the posts from the response array. The `attachments` key is coming as undefined.

 ![Screenshot from 2023-09-13 14-19-33](https://europe1.discourse-cdn.com/flex013/uploads/amity/original/1X/ec9f905cd1ecf616570f90b8ac7417e230aea46b.png)

Please provide a solution to get the uploaded file URLs in the Listing API.

I also noticed sometimes the response I am receiving from the API is not accurate. I have added a filter `includeDeletedPosts: true,` but this filter does not work all the time. Especially when I fetch the data for the first time.

I am using amity js SDK `"@amityco/js-sdk": "^5.37.0"`.

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 13, 2023, 1:03pm UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/2 "2023-09-13T13:03:48Z")

</div>

Hello, our team will help provide the code for the global feed query first. Once you have applied the correct code, we will further check for the existing issues.

---

<div class="post-metadata">

**Author:** ![Ashish](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Ashish](https://forum.social.plus/u/Ashish)\
**Post date:** [September 14, 2023, 4:35am UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/3 "2023-09-14T04:35:48Z")

</div>

Hello, Any update on this?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 14, 2023, 11:30am UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/4 "2023-09-14T11:30:49Z")

</div>

We have updated the code here: [Query Global Feed - Amity Docs](https://docs.amity.co/amity-sdk/social/feed/query-global-feed#conventional-global-feed-query) please apply this code and observe if the other issues still occur.

---

<div class="post-metadata">

**Author:** ![Ashish](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Ashish](https://forum.social.plus/u/Ashish)\
**Post date:** [September 14, 2023, 12:09pm UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/5 "2023-09-14T12:09:21Z")

</div>

Hey,  
Global feed APIs return my posts & the posts of the users I am following but I want to see only my posts. Is there any filter I can use to fetch only my posts?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 14, 2023, 1:40pm UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/6 "2023-09-14T13:40:02Z")

</div>

Are you referring to user’s feed, where contains posts you have posted on your personal feed? or posts that you have posted in communities?

---

<div class="post-metadata">

**Author:** ![Ashish](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Ashish](https://forum.social.plus/u/Ashish)\
**Post date:** [September 14, 2023, 1:53pm UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/7 "2023-09-14T13:53:09Z")

</div>

Is it possible to get both a user’s feed and a community feed? Only my post (both user and community) in a single API call?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 14, 2023, 2:18pm UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/8 "2023-09-14T14:18:35Z")

</div>

Unfortunately, no. The APIs you can use for querying posts, whether from a community or a user feed, are as follows:

1. [Query Posts API](https://api-docs.amity.co/#/Post/get_api_v3_posts): This API allows you to retrieve posts from user or community.
2. [User Feed API](https://api-docs.amity.co/#/UserFeed/get_api_v3_user_feeds__userId_): It enables you to fetch a paginated list of posts from a user’s feed.

---

<div class="post-metadata">

**Author:** ![Ashish](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Ashish](https://forum.social.plus/u/Ashish)\
**Post date:** [September 14, 2023, 2:30pm UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/9 "2023-09-14T14:30:15Z")

</div>

Okay, How about the files URL on listing API’s? I tried in both Community post API and User feed API. I am not receiving file urls in js/sdk. but Flutter SDK is returning the file URLs in the list APIs only.

I am taking example of below function:

```auto
      const liveCollection = await PostRepository.queryPosts(queryParams);

      let response = await new Promise((resolve) => {
        liveCollection.on("dataUpdated", (posts) => {
          resolve(posts);
        });
      });

```

If I upload an Image on the user feed I get this type of response

```auto
        {
            "_id": "6502deee06d",
            "path": "64a3333/social/user/64ffe15d7f63c/post/6502deee06d",
            "sharedCount": 0,
            "targetType": "user",
            "dataType": "text",
            "commentsCount": 0,
            "editedAt": "2023-09-14T10:18:51.849Z",
            "createdAt": "2023-09-14T10:18:51.849Z",
            "updatedAt": "2023-09-14T10:18:51.852Z",
            "isDeleted": false,
            "hasFlaggedComment": false,
            "hasFlaggedChildren": false,
            "data": {
                "text": "geberal wuth image"
            },
            "postId": "6502de0bd7006d",
            "postedUserId": "6363629dd500d1d",
            "targetId": "6363629dd330d1d",
            "flagCount": 0,
            "hashFlag": null,
            "reactions": {},
            "reactionsCount": 0,
            "myReactions": [],
            "comments": [],
            "children": [
                "6502de0b6656666565e070"
            ],
            "mentionees": [],
            "tags": []
        },

```

There is no file URL, Now I have to make an API call to fetch the details of below child post.

```auto
"children": [
                "6502de0b5656565ee070"
            ],

```

Once I receive data then again I have to fetch the file from the file Id I get from child data.

I am making 2 extra calls just to fetch the image/video URL.

But in Flutter SDK Image url’s are coming directly on the listing API.

How can I directly get the URLs on the list API’s?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 14, 2023, 2:51pm UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/10 "2023-09-14T14:51:34Z")

</div>

If there is an image/file in that post, it should return the _fileId_ this is an example via api call.

 ![Screenshot 2566-09-14 at 15.41.20](https://europe1.discourse-cdn.com/flex013/uploads/amity/original/1X/5869cec872f507764d5994c748319311b3b3dd91.png)

Could you pls share the steps you create that image post?

---

<div class="post-metadata">

**Author:** ![Ashish](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Ashish](https://forum.social.plus/u/Ashish)\
**Post date:** [September 14, 2023, 3:02pm UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/11 "2023-09-14T15:02:29Z")

</div>

// Create video file

```auto
const createVideoFile = async (fileObject) => {
  const liveFile = FileRepository.createVideo({ file: fileObject });
  const model = await new Promise((resolve) =>
    liveFile.once("dataUpdated", (data) => resolve(data))
  );
  return model;
};

```

// post user feed

```auto
const postNewsFeed = async (data) => {
  try {
      const payload = {
        targetType: PostTargetType.UserFeed,
        targetId: // targetId
        text: data.text,
      };

        const amityFile = await createVideoFile(data.videoIds[0]);
        payload.videoIds = [amityFile.fileId];

      const livePost = PostRepository.createVideoPost(payload);

      let response = await new Promise((resolve) => {
        livePost.once("dataUpdated", (model) => {
          resolve(model);
        });
      });

      livePost.on("dataError", (error) => {
        console.log(error, "error");
        throw Error(error);
      });

      return response;
    }
  } catch (error) {
    console.log(error);
    throw Error(error);
  }
};

```

After making the above call this is how my payload looks like in network tab

```auto
{
  "attachments": [
    {
      "fileId": "65031f4d3f3187907c0e26a4",
      "type": "video"
    }
  ],
  "metadata": {},
  "targetType": "user",
  "targetId": "6363629dd",
  "data": {
    "text": "Posting video feed"
  }
}

```

And this is the response from the API (I am sharing only post object I do get other object like “postChildren”, “user” etc…)

```auto
{
    "posts": [
        {
            "_id": "65031f5f287db2cc0",
            "path": "64a67c52725b00292f5f3333/social/user/64feaeca62c509fe15d7f63c/post/65031f5f287db2ceae8127c0",
            "sharedCount": 0,
            "targetType": "user",
            "dataType": "text",

            "commentsCount": 0,
            "editedAt": "2023-09-14T14:57:35.324Z",
            "createdAt": "2023-09-14T14:57:35.324Z",
            "updatedAt": "2023-09-14T14:57:35.328Z",
            "isDeleted": false,
            "hasFlaggedComment": false,
            "hasFlaggedChildren": false,
            "data": {
                "text": "Posting video feed"
            },
            "postId": "65031f5f287d127c0",
            "postedUserId": "6363629500d1d",
            "targetId": "6363629d500d1d",
            "flagCount": 0,
            "hashFlag": null,
            "reactions": {},
            "reactionsCount": 0,
            "myReactions": [],
            "comments": [],
            "children": [
                "65031f5f287db2aeae8127c3"
            ],
            "mentionees": [],
            "tags": []
        }
    ],

```

The same response I am getting in the listing. There are no URL’s

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 14, 2023, 3:09pm UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/12 "2023-09-14T15:09:35Z")

</div>

Did you upload the file to our platform before creating the post? You can refer to this documentation: [Upload Videos](https://docs.amity.co/amity-sdk/core-concepts/files-images-and-videos/video-handling#upload-videos), or utilize the APIs outlined in this section: [File APIs](https://api-docs.amity.co/#/File). After uploading the file, it will return a fileId, which you can then include when creating the post.

---

<div class="post-metadata">

**Author:** ![Ashish](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Ashish](https://forum.social.plus/u/Ashish)\
**Post date:** [September 14, 2023, 3:14pm UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/13 "2023-09-14T15:14:16Z")

</div>

```auto
const createVideoFile = async (fileObject) => {
  const liveFile = FileRepository.createVideo({ file: fileObject });
  const model = await new Promise((resolve) =>
    liveFile.once("dataUpdated", (data) => resolve(data))
  );
  return model;
};

```

I am using this function to upload file on your platform.

Please note: File issue is happening only in JS/SDK but Flutter SDK is sending file URLs for the same posts.

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 14, 2023, 3:18pm UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/14 "2023-09-14T15:18:21Z")

</div>

May I ask what is your current sdk version please?

---

<div class="post-metadata">

**Author:** ![Ashish](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Ashish](https://forum.social.plus/u/Ashish)\
**Post date:** [September 14, 2023, 3:24pm UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/15 "2023-09-14T15:24:12Z")

</div>

`"@amityco/js-sdk": "^5.37.0"` .

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 14, 2023, 3:27pm UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/16 "2023-09-14T15:27:25Z")

</div>

Got it, let us double check and will get back to you. Thank you for your cooperation and providing all the required information 🙂

---

<div class="post-metadata">

**Author:** ![topAmity](https://avatars.discourse-cdn.com/v4/letter/t/a88e4f/32.png) [@topAmity](https://forum.social.plus/u/topAmity)\
**Post date:** [September 15, 2023, 9:01am UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/17 "2023-09-15T09:01:04Z")

</div>

Hi @Ashish , The image posts will be appeared as children inside the parent post. You can use `PostRepository.postForId('6502de0b5656565ee070')` to query the image post detail. After you get the fileId, you can just put the fileId into this url [https://api.amity.co/api/v3/files/{fileId}/download?size=full](https://api.amity.co/api/v3/files/%7BfileId%7D/download?size=full) (size can be small, medium, large, full). No extra query needed to get the imageUrl.

---

<div class="post-metadata">

**Author:** ![Ashish](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Ashish](https://forum.social.plus/u/Ashish)\
**Post date:** [September 15, 2023, 12:03pm UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/18 "2023-09-15T12:03:23Z")

</div>

Hey,  
Don’t you think making the network request for getting the image URL is not a good approach?

I am rendering 20 posts at once and making the network request for all 20 posts will make the application slow.

---

<div class="post-metadata">

**Author:** ![Ashish](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Ashish](https://forum.social.plus/u/Ashish)\
**Post date:** [September 17, 2023, 5:23am UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/19 "2023-09-17T05:23:07Z")

</div>

Hey,  
The above method also not working. I called the API and got the file ID. But the URL you have provided is not working.

Refer to the image I have received the fileId.  
 ![Screenshot from 2023-09-17 10-48-08](https://europe1.discourse-cdn.com/flex013/uploads/amity/original/1X/06f7907d806c8f80a96bc83cb794c88443b4aad4.png)

Now if I append the ID on the URL I get the error  
`https://api.amity.co/api/v3/files/4cde9d2ccc5f48c7a27a0e5ffa29a739/download?size=full`

```auto
{
    "status": "error",
    "message": "File not found 4cde9d2ccc5f48c7a27a0e5ffa29a739",
    "code": 400400,
    "data": {
        "detail": {}
    }
}

```

This is happening for all the files.

---

<div class="post-metadata">

**Author:** ![topAmity](https://avatars.discourse-cdn.com/v4/letter/t/a88e4f/32.png) [@topAmity](https://forum.social.plus/u/topAmity)\
**Post date:** [September 19, 2023, 10:09am UTC](https://forum.social.plus/t/not-receiving-image-urls-in-fetch-request-of-all-post/918/20 "2023-09-19T10:09:01Z")

</div>

In that case, Can you try specify the region inside the URL?

`https://api.us.amity.co/api/v3/files/4cde9d2ccc5f48c7a27a0e5ffa29a739/download?size=full`
