How to post data into collection from plugin frontend?

Just want to leave this out there, cause it took me some time to figure out.
To get and update collections from your plugin component, do this

import { request } from 'strapi-helper-plugin';

const getCollectionData = async () => {
  const data = await request("/collections?<filter-conditions>");
  return data;
}

const updateCollectionData = async (id) => {
  const data = {
      fieldA: "Hello World"
    };
    await request(
      `/collections/${id}`,
      {
        method: 'PUT',
        headers: {
          'Content-Type': 'application/json'
        },
        body: data
      },
    );
    console.log("collections updated");
}

1 Like