react-gravity-form
Advanced tools
Comparing version 0.0.4 to 0.0.5
23
index.js
@@ -7,2 +7,3 @@ import React, { Component } from "react"; | ||
import Submit from "./FormElements/Submit"; | ||
import axios from "axios"; | ||
@@ -32,9 +33,5 @@ class GravityForm extends Component { | ||
this._isMounted = true; | ||
const form = await fetch(`${backendUrl}/v1/gravityforms/${formID}`) | ||
.then(response => { | ||
if (response.ok) { | ||
return response.json(); | ||
} | ||
throw new Error(); | ||
}) | ||
const form = await axios | ||
.get(`${backendUrl}/v1/gravityforms/${formID}`) | ||
.then(response => response.data) | ||
.catch(() => false); | ||
@@ -194,16 +191,14 @@ | ||
const data = new FormData(event.target); | ||
const req = await fetch( | ||
const response = await axios.post( | ||
`${backendUrl}/v1/gravityforms/${formID}/submissions`, | ||
{ | ||
method: "POST", | ||
body: data | ||
data | ||
} | ||
); | ||
const response = await req.json(); | ||
if (response.is_valid) { | ||
if (response.data && response.is_valid) { | ||
this.setState({ | ||
submitting: false, | ||
submitSuccess: true, | ||
confirmationMessage: response.confirmation_message | ||
confirmationMessage: response.data.confirmation_message | ||
}); | ||
@@ -214,3 +209,3 @@ } else { | ||
submitFailed: true, | ||
errorMessages: response.validation_messages | ||
errorMessages: response.data.validation_messages | ||
}); | ||
@@ -217,0 +212,0 @@ } |
{ | ||
"name": "react-gravity-form", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "A component for including Gravity Forms on React apps via the Wordpress API", | ||
@@ -29,4 +29,5 @@ "main": "index.js", | ||
"devDependencies": { | ||
"react": "^16.8.1" | ||
"react": "^16.8.1", | ||
"axios": "^0.19.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
0
52895
2
1846