How should I customize controllers in order to sent POST request?

goodhoko, thank you for your valuable time.

I followed Method 1 for creating controller inside src > api > [folder-name] > controllers > [file-name.js], and I putted the following code inside it:


"use strict";

const { createCoreController } = require("@strapi/strapi").factories;

module.exports = createCoreController("api::request.request", ({ strapi }) => ({
  // Method 1: Creating an entirely custom action
  async exampleAction(ctx) {
    try {
      console.log(ctx);
      ctx.body = "ok";
    } catch (err) {
      ctx.body = err;
    }
  },
}));

I also created route in routes folder.

Every time when I try to make POST request to the following endpoint trough Postman:
http://localhost:1337/api/requests

I am getting a string “ok” as a response. How could I change this into a data that user entered thought some input form? Or, let say, data that I am sending thought Postman?

thank you.

1 Like