Skip to content

[DOCS ISSUE] Page: Front end helper methods #226

@Fabien-Scetbon

Description

@Fabien-Scetbon

Hello everybody, i'm a french junior dev on apostrophecms3.
Here is my problem :
I have a customer module with a favorites field :

favorites: {
label: 'apostrophe:favorites',
type: 'array',
titleField: 'favorite',
fields: {
add: {
type: {
type: 'string',
label: 'apostrophe:favoriteType',
},
id: {
type: 'string',
label: 'apostrophe:favoriteId',
},
}
}
},

I would like to add a new favorite for this customer by clicking a button on the article page.

But i can't find the way to do it in my index.js front file.

Here is a part of my code :

favorite.addEventListener('click', () => {

      addFavorite(favorite.id)  // favorite.id is defined
   
    })

async function addFavorite(favoriteId) {

  const customerId = sessionStorage.getItem('aposCustomerId')

  try {
    
        ???? what's going on here ????
  
  } catch (err) {
    console.error(err)
  } finally {
  }
}

Thanks a lot for your help !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions