In AstroJS get a single record from Strapi database

System Information
  • Strapi Version: v4.13.2
  • Operating System: Ventura 13.5.2
  • Database: MySQL
  • Node Version: v18.17.1
  • NPM Version: 9.6.7
  • Yarn Version: na

In AstroJS (I’m new) I’m able to retrieve my full Strapi table data using these lines of code:

const response = await fetch("http://127.0.0.1:1337/api/teams?populate=");*
const { data } = await response.json();

Or using the Filters option to get a specific result eg

http://127.0.0.1:1337/api/teams?filters[name][$contains]=john;
const { data } = await response.json();

Both above is placed in JSON data.

I would like to use the finOne function that Strapi has in their documentation.

const entry = await strapi.db.query(‘api::blog.article’).findOne({

  • select: [‘title’, ‘description’],*
  • where: { title: ‘Hello World’ },*
  • populate: { category: true },*
    });
  1. My first question is what is api:::blog.artilce? I only have Strapi table names like Content and Teams.
  2. My second question is why am I getting a error “strapi is not defined” when changing the api to my teams table?

const entry = await strapi.db.query(‘http://127.0.0.1:1337/api/teams’).findOne({

  • select: [‘title’, ‘name’],*
  • where: { name: ‘john’ },*
  • populate: { category: true },*
    });

suggestion use Entity service over qb.query you can also get a single record of /api/teams/X where X is the ID

I still get an error “strapi is not defined”. My frontend AstroJS project is running on http://localhost:4321/ and Strapi http://localhost:1337/. Do I need to build a end point for Strapi to Astro?