fix: change to key value type not show init key values

This commit is contained in:
Joel 2024-08-29 11:55:18 +08:00
parent 2a6629d435
commit dae62bef78

View File

@ -63,9 +63,19 @@ const EditBody: FC<Props> = ({
const handleTypeChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
const newType = e.target.value as BodyType
const hasKeyValue = [BodyType.formData, BodyType.xWwwFormUrlencoded].includes(newType)
onChange({
type: newType,
data: [],
data: hasKeyValue
? [
{
id: uniqueId(UNIQUE_ID_PREFIX),
type: BodyPayloadValueType.text,
key: '',
value: '',
},
]
: [],
})
}, [onChange])