How to get current $page to custom field plugin route

I have built a custom field plugin which fetches data from a third party API. Included in this data is an image that I would like to save to the page folder in ‘content’.

My field is setup as a Vue template and calls custom routes defined in the index.php of the plugin. Some of the text returned data is saved into fields on the page using JS methods in the Vue component. That all works. Now I want to create a new image in the page folder?

Is there an easy way to either (a) get at the $page object for the $page sending the request to the custom route, or (b) do I have to pass a value from the front-end Vue component with the page id to do that?

The solution I settled on is getting the current page 'id' by retrieving the'endpoints' attribute through a prop, doing a bit of string manipulation to format it into the php $page->id() format, and then passing that to this.$api.get() as a parameter:

export default {
  props: {
    endpoints: {
      type: Object,
      default: null

const page = this.endpoints.model.replace('pages/', '')
this.$api.get('path/to/endpoint?p=' + page.replace(/\+/g, '/'))

Not sure if it’s the “best” way, but it works.