Check if user can in javascript

Using the rest API I retrieve a collection of posts:

const recordsParams = {}
const recordsCollection = new wp.api.collections.MyPostType();
recordsCollection.fetch( { data: recordsParams } )
    .then( records = {
        this.records = records
    } ).catch( error = {
    console.log( error );
} )

I then loop on each retrieved post and I need an equivalent to the PHP's ?php current_user_can('edit_myposttype', $post_id); ? in order to check if the current user can edit each post and act accordingly.

Is there something equivalent in the WordPress JavaScript API ?

I found a canUser(state, action, resource, id) function in core-data.js, but I can't get how to invoke and use it.

Or is there any other way to achive my goal ?

Topic wp-api backbone rest-api Wordpress javascript

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.