Extract the json object from the response

Last update: 2023-11-30
  • Created for:
  • Beginner
    Intermediate
    Developer

When you submit headless adaptive form to an custom submit handler, the data returned by the submit handler can be extracted and displayed in your react app. The following code snippet shows

// 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");

      }

On this page