mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Change some API calls to use getEndpoint utility (#8180)
This commit is contained in:
@@ -6,6 +6,7 @@ import { addRelatedPrimaryKeyToFields } from '@/utils/add-related-primary-key-to
|
||||
import { cloneDeep, get, merge } from 'lodash';
|
||||
import { Ref, ref, watch } from 'vue';
|
||||
import { RelationInfo } from './use-relation';
|
||||
import { getEndpoint } from '@/utils/get-endpoint';
|
||||
|
||||
type UsablePreview = {
|
||||
tableHeaders: Ref<Header[]>;
|
||||
@@ -194,11 +195,9 @@ export default function usePreview(
|
||||
) {
|
||||
if (fields === null || fields.length === 0 || primaryKeys === null || primaryKeys.length === 0) return [];
|
||||
|
||||
const endpoint = collection.startsWith('directus_') ? `/${collection.substring(9)}` : `/items/${collection}`;
|
||||
|
||||
const fieldsToFetch = addRelatedPrimaryKeyToFields(collection, fields);
|
||||
|
||||
const response = await api.get(endpoint, {
|
||||
const response = await api.get(getEndpoint(collection), {
|
||||
params: {
|
||||
fields: fieldsToFetch,
|
||||
[`filter[${filteredField}][_in]`]: primaryKeys.join(','),
|
||||
|
||||
@@ -38,6 +38,7 @@ import DrawerItem from '@/views/private/components/drawer-item';
|
||||
import { unexpectedError } from '@/utils/unexpected-error';
|
||||
import { getFieldsFromTemplate } from '@directus/shared/utils';
|
||||
import { adjustFieldsForDisplays } from '@/utils/adjust-fields-for-displays';
|
||||
import { getEndpoint } from '@/utils/get-endpoint';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
export default defineComponent({
|
||||
@@ -128,7 +129,7 @@ export default defineComponent({
|
||||
try {
|
||||
const sort = props.sortField;
|
||||
|
||||
const res = await api.get(`/items/${props.collection}`, {
|
||||
const res = await api.get(getEndpoint(props.collection), {
|
||||
params: {
|
||||
fields: [
|
||||
primaryKeyField.value.field,
|
||||
|
||||
@@ -17,6 +17,7 @@ import { Filter } from '@directus/shared/types';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { abbreviateNumber } from '@/utils/abbreviate-number';
|
||||
import { isNil } from 'lodash';
|
||||
import { getEndpoint } from '@/utils/get-endpoint';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
@@ -156,7 +157,7 @@ export default defineComponent({
|
||||
[props.function]: [props.field || '*'],
|
||||
};
|
||||
|
||||
const res = await api.get(`/items/${props.collection}`, {
|
||||
const res = await api.get(getEndpoint(props.collection), {
|
||||
params: {
|
||||
aggregate,
|
||||
filter: props.filter,
|
||||
|
||||
@@ -12,6 +12,7 @@ import { isEqual, isNil } from 'lodash';
|
||||
import { useFieldsStore } from '@/stores';
|
||||
import { Filter } from '@directus/shared/types';
|
||||
import { abbreviateNumber } from '@/utils/abbreviate-number';
|
||||
import { getEndpoint } from '@/utils/get-endpoint';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
@@ -134,7 +135,7 @@ export default defineComponent({
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
const results = await api.get(`/items/${props.collection}`, {
|
||||
const results = await api.get(getEndpoint(props.collection), {
|
||||
params: {
|
||||
groupBy: getGroups(),
|
||||
aggregate: {
|
||||
|
||||
Reference in New Issue
Block a user