Create a single_line_text_field metafield

The type of the metafield you're going to create depends on the Raven carrying the message. If the value you're sending doesn't match the value type expected, the request will result in an error.

<!-- JavaScript + Liquid -->
<script type="text/javascript">
  fieldsRavenSubmit = (value) => {
    const ravenObj = {%- render 'raven-mac-gen', resource_id: page.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('Hello Raven!')">Send the Raven!</button>

Last updated