This repository was archived by the owner on Feb 27, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
components/molecules/GravityForm Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -25,17 +25,29 @@ export default function GravityForm({
25
25
const formValidationSchema = getGfFormValidationSchema ( fieldData )
26
26
const fieldDefaults = getGfFormDefaults ( fieldData )
27
27
28
+ // fetch('/api/wp/getWPUrl')
29
+ // .then((result) => result.json)
30
+ // .then((parsed) => {
31
+ // wpBase = parsed.wpApiUrlBase
32
+ // })
33
+
28
34
return (
29
35
< Form
30
36
className = { cn ( styles . gravityForm , cssClass ) }
31
37
formDefaults = { fieldDefaults }
32
38
id = { formId && `gform-${ formId } ` }
33
39
validationSchema = { formValidationSchema }
34
- onSubmit = { ( values ) => {
35
- const formApiUrl = `https://nextjswp.test/wp-json/gf/v2/forms/${ formId } /submissions`
40
+ onSubmit = { async ( values ) => {
41
+ const wpBaseRequest = await fetch ( '/api/wp/getWPUrl' )
42
+ const wpBaseObject = await wpBaseRequest . json ( )
43
+ const wpBase = wpBaseObject . wpApiUrlBase
44
+
45
+ const formApiUrl = `${ wpBase } wp-json/gf/v2/forms/${ formId } /submissions`
36
46
const formData = new FormData ( )
37
47
const formKeys = Object . keys ( values )
38
48
49
+ formData . append ( 'form_id' , formId )
50
+
39
51
formKeys . forEach ( ( key ) => {
40
52
let fieldName = key . replaceAll ( '-' , '_' )
41
53
if ( fieldName . endsWith ( '_filedata' ) ) {
Original file line number Diff line number Diff line change
1
+ import { wpApiUrlBase } from '@/api/wordpress/connector'
2
+
3
+ /**
4
+ * Load more posts for an archive.
5
+ *
6
+ * @author WebDevStudios
7
+ * @param {object } req Instance of http.IncomingMessage.
8
+ * @param {object } res Instance of http.ServerResponse.
9
+ */
10
+ export default function getWPUrl ( req , res ) {
11
+ res . status ( 200 ) . send ( { wpApiUrlBase} )
12
+ }
You can’t perform that action at this time.
0 commit comments