從回應中擷取json物件

當您將Headless最適化表單提交至自訂提交處理常式時,可擷取提交處理常式傳回的資料,並將其顯示在您的react應用程式中。 下列程式碼片段顯示

// associate event handler for the onSubmitSuccess event
<AdaptiveForm mappings={extendMappings} onSubmitSuccess={onSuccess} formJson={selectedForm}/>
// extract the json returned by the custom submit service
const onSuccess=(action) =>{
        let body = action.payload?.body;
        let FirstName = JSON.parse(body.metadata.json).firstName;
        setThankYouMessage(FirstName+" your request has been received");

      }
recommendation-more-help
4859a77c-7971-4ac9-8f5c-4260823c6f69