NoMethodError (undefined method `permit' for #<Array:0x0000563ea01dba98>):

Viewed 30
    const postData = { "post": [{
        "title": values.title,
        "location": values.location,
        "img_url": values.imageUrl,
        "description": values.description,
    }]};
    console.log(postData)

    fetch('/posts', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(postData)
    })

 NoMethodError (undefined method `permit' for #<Array:0x0000563ea01dba98>):
  
app/controllers/posts_controller.rb:49:in `post_params'
app/controllers/posts_controller.rb:18:in `create'

I'm trying to post using the method shown to my ruby on rails backend and I keep getting the error.

1 Answers

Welp I answered my own question the const im using should be formatted like this instead

const postData = {
        title: values.title,
        location: values.location,
        img_url: values.imageUrl,
        description: values.description,
    };
Related