Must be of type 'array', got ([object Object])]


#1

Hi everyone ,

i have 2 schema, Schema User

UserSchema.schema = {
name: ‘User’,
properties: {
info :{type:‘list’, objectType:‘Data’ },
}}

and Data Schema

DtSchema.schema = {
name: ‘Data’,
properties:{
one: {type:‘string’, optional: true, default: ’ '},
two: {type:‘string’, optional: true, default: ’ '},
thre:{type:‘string’, optional: true, default: ’ '},
}
}

i get data from rest api and populate the schemas , but i get an error must be of type ‘array’, got ([object Object])].

any idea ?


#2

Are you sure that your server returns an array of objects and not just an object? The JSON should look like: {info: [{one: '1', two: '2', thre: '3'}]}.


#3

the Json is
{ ‘info’ : { ‘one’ : ’ 1 ', ‘two’ : ’ 2 ’ } }

and i still get error with {info: [{one: ‘1’, two: ‘2’, thre: ‘3’}]}.


#4

The solution is

UserSchema.schema = {
name: ‘User’,
properties: {
info :{type:‘Data’ },
}}