P
P
POLONSKY972021-04-30 16:13:27
React
POLONSKY97, 2021-04-30 16:13:27

React, Ant-Design. How to fix the problem of submitting data through the form?

Who used Ant design in React, tell me what could be the reason? When I send POST data in the form via and (Ant design) then the status code is 400 and in the form in the headers "undefined" it is as if the data was not sent, but if through plain HTML and then everything passes status - 201. Here is a piece of code

<Form
                  labelCol={{ span: 4, }}
                  wrapperCol={{ span: 12, }}
                  layout="horizontal"
                  onFinish={this.handleFinish}
                >

                  <Form.Item
                    name='category'
                    label="Категория"
                    rules={[
                      {
                        required: true,
                        message: 'Пожалуйста выберите категорию',
                      },
                    ]}
                    onChange={this.handleCategoryChange}
                  >
                    <Select
                      onChange={this.handleChange}
                      type='number'
                      allowClear
                      placeholder='Выберите категорию'
                    >
                      {categories.map(function (category) {
                        return (
                          <Select.Option
                            value={category.id}
                            key={category.id}
                          >{category.name}
                          </Select.Option >
                        )
                      })}
                    </Select>
                  </Form.Item>
               </Form>

608c018e5b48a606082341.jpeg
Here is a normal select via html
<Form
                  labelCol={{ span: 4, }}
                  wrapperCol={{ span: 12, }}
                  layout="horizontal"
                  onFinish={this.handleFinish}
                >

                  <Form.Item
                    name='category'
                    label="Категория"
                    rules={[
                      {
                        required: true,
                        message: 'Пожалуйста выберите категорию',
                      },
                    ]}
                    onChange={this.handleCategoryChange}
                  >
                    <select
                      onChange={this.handleChange}
                      type='number'
                      allowClear
                      placeholder='Выберите категорию'
                    >
                      {categories.map(function (category) {
                        return (
                          <option
                            value={category.id}
                            key={category.id}
                          >{category.name}
                          </option>
                        )
                      })}
                    </select>
                  </Form.Item>
</Form>

608c0214ee7d4632587445.jpeg

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question