So I have this small piece of code that renders an array of IDs:
const selected = this.$data.list.selected;
function get_ids(input, field) {
const output = [];
for (let i=0; i < input.length ; ++i)
output.push(input[i][field]);
return output;
}
const result = get_ids(selected, "id");
Now inside my JS, I want to be able to use the backbone.js API that WordPress provides to save it to my employee custom post type as a post meta.
So let's say that my result output is [343, 3532]
- I want to be able to save that array as a "apps" post meta under employees.
I know examples showed that it would be something like const test = new wp.api.models.Employee().fetch and then save
, but it sounds super confusing since I don't have a specific post, and would just like to save the post meta.
Based on these examples, does anyone know how I could do that?