【问题标题】:Store PhoneInput and Select value in DynamoDB AWS ReactJS在 DynamoDB AWS ReactJS 中存储 PhoneInput 和 Select 值
【发布时间】:2021-01-30 14:56:59
【问题描述】:

我需要在 DynamoDB 中存储 <PhoneInput> 电话号码值和 <Select> 标记国家/地区输入。当我尝试提交时,它没有反映在我的数据库中。那么我必须做出哪些改变。 我用过:npm react-phone-number-inputnpm react-select-country-list

提前致谢。

<PhoneInput 
     className="phone"
     placeholder="Enter phone number"
     value={value}
     onChange={setValue} name="phonenumber" /> 
<Select className="react-select-country-list" options={options}
    name="country" value={value} onChange={changeHandler} />
 async function addContact() {
    const data = {
        body: {
            first_name: formState.first_name,
            last_name: formState.last_name,
            email: formState.email,
            phonenumber: formState.phonenumber,
            help: formState.help,
            country: formState.country,
            message: formState.message
          

        }
    }
        console.log(data);
        const apiData = await API.post('contact', '/contacts', data);
        console.log({ apiData };
        alert('Mail sent');
};

【问题讨论】:

  • 听起来您的 API 端点没有按预期工作。可以发一下 API 代码吗?
  • 但是输入标签被存储在我的数据库中,&lt;input name="first_name" onChange={e =&gt; updateFormState('first_name', e.target.value)} type="text" required className="form-control" /&gt;,只有 PhoneInput 和 Select 没有被存储

标签: reactjs amazon-web-services amazon-dynamodb amplify


【解决方案1】:

通过更改 onChange = onChange={x => updateFormState('phonenumber', x)} 解决它

【讨论】:

    猜你喜欢
    • 2013-08-15
    • 2022-11-16
    • 2019-09-09
    • 1970-01-01
    • 1970-01-01
    • 2017-07-21
    • 1970-01-01
    • 1970-01-01
    • 2012-08-16
    相关资源
    最近更新 更多