apostrophecms / apostrophecms/docs

[DOCS ISSUE] Page: Front end helper methods

Open
#226 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
6
Forks
18
Avg merge
5d 7h
Merged PRs (30d)
4

Description

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 !

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.