【发布时间】:2021-01-30 14:56:59
【问题描述】:
我需要在 DynamoDB 中存储 <PhoneInput> 电话号码值和 <Select> 标记国家/地区输入。当我尝试提交时,它没有反映在我的数据库中。那么我必须做出哪些改变。
我用过:npm react-phone-number-input 和 npm 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 代码吗?
-
但是输入标签被存储在我的数据库中,
<input name="first_name" onChange={e => updateFormState('first_name', e.target.value)} type="text" required className="form-control" />,只有 PhoneInput 和 Select 没有被存储
标签: reactjs amazon-web-services amazon-dynamodb amplify