admin管理员组

文章数量:1279008

I am trying to make a Post Web App using Appwrite. I am able to upload the images but not view them in all posts for anonymous reason.

config.js:

async getPosts(queries = [Query.equal("status", "active")]){
  try {
    return await this.databases.listDocuments(
      conf.appwriteDatabaseId,
      conf.appwriteCollectionId,
      queries,
    )
  } catch (error) {
    console.log("Appwrite serive :: getPosts :: error", error);
    return false
  }
}

All posts.jsx:

import React, { useState, useEffect } from 'react'
import { Container, PostCard } from '../components'
import appwriteService from "../appwrite/config";

function AllPosts() {
  const [posts, setPosts] = useState([])

  useEffect(() => {}, [])

  appwriteService.getPosts([])
    .then((posts) => {
      if (posts) {
        setPosts(posts.documents)
      }
    })

  return (
    <div className='w-full py-8'>
      <Container>
        <div className='flex flex-wrap'>
          {posts.map((post) => (
            <div key={post.$id} className='p-2 w-1/4'>
              <PostCard {...post} />
            </div>
          ))}
        </div>
      </Container>
    </div>
  )
}

export default AllPosts

I tried to check full Appwrite configs but still nothing changed. I also tried ChatGPT but it failed. The length of post is always 0.

本文标签: javascriptHow to list all posts from AppwriteStack Overflow