#[SOLVED] AppwriteException: Invalid document structure: Attribute "color" has invalid type.

41 messages · Page 1 of 1 (latest)

trim silo
#

Hi !

#

is it regarding the upload file section you made previously?

quaint lotus
quaint lotus
trim silo
#

can you copy paste the 49926 and 49559 lines from bundle.js if available to you? they seem to throw errors

quaint lotus
#

once please check this code is this the correct way to store values to appwrite const handleChange = (event) => { props.setSelectedValue(event.target.value); database({ color:'' }).then(function (response) { console.log(response); }, function (error) { console.log(error); }); } const handleChange2 = (event)=>{ props.setSelectedValue2(event.target.value); database( { side:'' } ).then(function (response) { console.log(response); }, function (error) { console.log(error); }); }

#

49926: if (400 <= response.status) {
throw new AppwriteException(data === null || data === void 0 ? void 0 : data.message, response.status, data === null || data === void 0 ? void 0 : data.type, data);
}

#

49559:try {
step(generator.next(value));
}

#

@flat palm please check this once

flat palm
#

What is the type of the attribute color?

trim silo
#

your code says color:'black' - but radio might send back ? - you do have separate options for black and white and colored right?

#

in the second code piece you do it empty string, which one is the original code?

quaint lotus
flat palm
#

Where is the original code?

flat palm
#

Where you get the error?

quaint lotus
#

AppwriteException: Invalid document structure: Attribute "color" has invalid type. Value must be a valid string and no longer than 100 chars

quaint lotus
trim silo
#

so when radio button selects a value -> you should be sending that back to update the DB about the color, empty string will be replaced by your color. I do not think the updation is happening and hence, it is showing error?

quaint lotus
quaint lotus
# flat palm Where is the original code?
    props.setSelectedValue(event.target.value);
    database({
      color:''
    }).then(function (response) {
          console.log(response);
      }, function (error) {
          console.log(error);
      });
}
const handleChange2 = (event)=>{
  props.setSelectedValue2(event.target.value);
  database(
    {
      side:''
    }
    ).then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
}```
flat palm
#

What logs you get for this part?

database({
      color:''
    }).then(function (response) {
          console.log(response);
      }, function (error) {
          console.log(error);
      });
quaint lotus
#

Or

#

Color

flat palm
#

What is the log of the database function

quaint lotus
#

Do you mean console log

flat palm
#

Yes

quaint lotus
#

Users radio button input

flat palm
#

Do you get error when running the database function?

quaint lotus
#

Yes

flat palm
#

What is the error?

quaint lotus
flat palm
#

Show me the payload inside the network tab

quaint lotus
#

Ok

quaint lotus
flat palm
#

Okay, you're sending color as an object when it is a string
Just change the value to string and you're good to go

karmic agate
#

closing as original message was deleted so i think it was resolved