Vanilla JS FieldsRaven Fetch wrapper (aka Storefront JS Kit)
Copy <!-- JavaScript + Liquid -->
< script type = "text/javascript" >
fieldsRavenSubmit = (value) => {
const ravenObj = {%- render 'raven-mac-gen' , resource_id : customer .id , raven_id : 'TBD' -% }
const valueObj = { value : value };
const requestParams = { raven : Object .assign ({} , ravenObj , valueObj) };
const response = fetch ( '/apps/raven/create_metafield' , {
method : 'PUT' ,
headers : { 'Content-Type' : 'application/json' } ,
body : JSON .stringify (requestParamsOne)
})
response
.then (res => res .json ())
.then (resJson => console .log ( 'resJson: ' , resJson))
}
</ script >
<!-- HTML -->
< button id = "fieldsraven-demo" onclick = " ravenSubmit ('{{ product.id }}')" >Send the Raven!</ button >
Copy <!-- JavaScript + Liquid -->
< script type = "text/javascript" >
fieldsRavenSubmit = (value) => {
const ravenObj = {%- render 'raven-mac-gen' , resource_id : customer .id , raven_id : 'TBD' -% }
const valueObj = { value : value };
const requestParams = Object .assign ({} , ravenObj , valueObj);
const response = FieldsRaven .send (requestParams);
response .then (res => {
if ( res .status === 200 ) {
console .log ( '🎉' , res .json)
} else {
console .error ( '😞' , res)
}
})
.catch (e => console .error (e));
}
</ script >
<!-- HTML -->
< button id = "fieldsraven-demo" onclick = " ravenSubmit ('{{ product.id }}')" >Send the Raven!</ button >