Is it possible to receive a JSON that isn't part of a field?

Hi there. I’m working on a hacky solution to getting deploy notifications form Netlify, and, long story short, I’m wandering if it’s possible for a Strapi content-type to receive a JSON that isn’t part of a field (since I have no control of the JSON Netlify sends)?

Thanks

hi @ruben00001

Yes it is possible but it depends on the context of how you want to see/use it. Are you wanting to pull in this information to an entry in the Admin panel or only as a part of a response from the REST/GraphQL?

1 Like

Cheers. That’s great. I only need the info as part of a REST response.

In that case I would suggest creating/overriding a controller.

We list all of the example code for the default controllers on our documentation here: https://strapi.io/documentation/developer-docs/latest/concepts/controllers.html#core-controllers

Basically what you would do (in the example of a findOne):

const { sanitizeEntity } = require('strapi-utils');

module.exports = {
  /**
   * Retrieve a record.
   *
   * @return {Object}
   */

  async findOne(ctx) {
    const { id } = ctx.params;

    const entity = await strapi.services.restaurant.findOne({ id });
    let cleanEntity = sanitizeEntity(entity, { model: strapi.models.restaurant });

   // Inject your custom json from some external await call into cleanEntity

   return cleanEntity;
  },
};
1 Like