Answer the question
In order to leave comments, you need to log in
Explain the logic error in the component?
Given:
the user object
in the user includes the articles array (here id (12,13,14,15))
To add an article to the user, I do the following, I will indicate the comments in the code
try {
this.bookmarks = await this.user.articles.map(function (ids) {
return ids.id; //получаю массив с ID
});
this.query = await id.concat(this.bookmarks); //добавляю ID нового article в массив articles с последующим созданием нового массива query
this.user = await this.$strapi.$users.update("me", {
articles: this.query, // отправляю данные на сервер для обновления
});
} catch (e) {
this.error = e.response.data.message[0].messages[0].message;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question