Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

What's the proper way to access database/api?

Open
#42 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
express, typescript
Domain
api, backend, database

Research direction

Start with the +handler.js example and the +page.marko access shown in the issue, then trace Marko Run's request and data-loading entry points. Done means identifying and documenting the supported way to fetch database or API data for a page, including how the handler's result is consumed.

Written by the indexing model from the issue text.

Description

Let's say I want to fetch products from the database.

that's the old way:

import express from "express";
import markoPlugin from "@marko/express";
import template from "./template.marko";

const app = express();
app.use(markoPlugin()); // Enables `res.marko(template, input)`

app.get("/", function (req, res) {
  const products = req.db.find(...)

  res.marko(template, {
    products
  });
});

app.listen(8080);

What's the proper way to do the same in marko/run?

I tried something like this in +handler.js

export const GET: MarkoRun.Handler = ({ request, platform }, next) => {
    platform.response.locals = {
        data: Math.random()
    }

    next()
};

and then in +page.marko
<h1>${$global.platform.response.locals.data}</h1>
but i'm not sure it's the best way.

Dominant language
TypeScript
Stars
175
Forks
16
Avg merge
3d 12h
Merged PRs (30d)
6

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from marko-js/run

All issues in marko-js/run

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.