Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The type of \"value\" is incorrect, expected type: Object #1719

Open
pguardiario opened this issue Mar 7, 2023 · 2 comments
Open

The type of \"value\" is incorrect, expected type: Object #1719

pguardiario opened this issue Mar 7, 2023 · 2 comments

Comments

@pguardiario
Copy link

I'm trying to create an entry:

let ct = await environment.createContentTypeWithId('showcase', {
      name: 'Showcase',
      fields: [
        {
          id: 'title',
          name: 'Title',
          required: true,
          localized: false,
          type: 'Text'
        }
    ]
})

await ct.publish()

let entry = await environment.createEntry('showcase', {
      fields: {
        title: "testing"
      }
})

Can someone explain what the error message means and tell me the solution please?

@mgoudy91
Copy link
Contributor

Is this still an issue? Could you provide the error message you're getting if so?
Thanks!

@rustyy
Copy link

rustyy commented Mar 19, 2024

I've also seen this error and it's probably the missing default-locale causing the issue. In terms of the CMA you need to be aware to provide the proper locales to make it work.
Providing the locale might fix it (en-US is assumed to be the default locale below):

let entry = await environment.createEntry('showcase', {
  fields: {
    title: 
      "en-US": "testing"
    }
})

to receive default locale you could do something like:

const locales = await env.getLocales()
const defaultLocale = locales.items.find(locale => locale.default)
// fallback to a "default default" or throw an error , whatever fits your needs
const localeCode = defaultLocale?.code || 'en-US';

let entry = await environment.createEntry('showcase', {
  fields: {
    title: 
      [localeCode]: "testing"
    }
})

Sadly, neither the legacy api environment.getLocales() nor the plain-interface client.locale.getMany() provides the possibility to filter default locale at request time - although the plain-api provides the query parameter, which is not working.

await client.locale.getMany({
    environmentId: "my-environment",
    spaceId: "my-space",
    query: {
        "default": true // won't work
    }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants