Hey there I need to submit a google form using an API, there are three fields in google form name, email & profile, which are identified as “entry.575833505”, “entry.1168209987” & “entry.1027774066” respectively. The code is as follows
in backend “backend.jsw”
export function getcertificate () {
let endPoint = “https://docs.google.com/forms/u/0/d/e/1FAIpQLSemY58g-nMoFe9KfetmJLGGYnTeMbfQJgyhR9RDhNr5iEI30A/formResponse”
let name = “Test User Name”
let email = “testuser@email.com”
let profile = “testuser”
return fetch ( endPoint , {
‘method’ : ‘post’ ,
‘headers’ : {
‘Content-Type’ : ‘application/x-www-form-urlencoded’
},
‘body’ : JSON . stringify ({ “entry.575833505” : name , “entry.1168209987” : email , “entry.1027774066” : profile })
})
. then (( httpResponse ) => {
if ( httpResponse . ok ) {
console . log ( “inside if part of then” )
return httpResponse . json ();
} else {
console . log ( “inside else part of then” )
return Promise . reject ( ‘Fetch did not succeed’ );
}
})
. then (( json ) => {
console . log ( “inside then” )
return json . result ;
})
. catch ( err => console . log ( error: ${ err }
));
}
Calling the module from the front end with the click of a button
export async function getcert_click ( event ) {
var resp = await getcertificate ()
console . log ( response: ${ resp }
)
}
In the console, I see this error " response: undefined ", even I tested API in Postman and it was submitting values. Please help and let me know what I am doing wrong. Thanks in advance!