INNER CODE UNIT · JavaScript

upsertItem

ChatFAQ/ChatFAQ · admin/utils/index.js:132

export async function upsertItem(apiUrl, item, itemStore, updateItems = false, params = {}, $t) {
    const { $axios } = useNuxtApp()

    let res;
    try {
        itemStore.savingItem = true;
        if (item.id) {
            res = (await $axios.patch(`${apiUrl}${item.id}/`, item, { "headers": authHeaders() })).data;
        } else {
            res = (await $axios.post(apiUrl, item, { "headers": authHeaders() })).data;
        }
        if (updateItems)
            await itemStore.retrieveItems(apiUrl, params);
        itemStore.savingItem = false;
    } catch (e) {
        ElNotification({
            title: "Error",
            message: $t("failedaction"),

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…