[Vuejs]-NuxtJS axios post to cockpit CMS

0👍

I previously worked with c**kpit cms and nuxtjs and i can say a couple of things are different from how you made your request.

  1. You failed to pass the headers
  2. Use JSON.stringify

    axios.post(
    'https://something.com/api/forms/submit/contact?token=XXX',
    JSON.stringify({
    form: {
    name: this.name,
    model: this.carModel,
    service: this.service,
    number: this.models.phoneNumber
    }
    }),
    {
    headers: {
    'Content-Type': 'application/json'
    }
    }
    )

    Similar to the example on the docs

    fetch('/api/forms/submit/c**kpitForm?token=xxtokenxx', {
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
    form: {
    field1: 'value1',
    field2: 'value2'
    }
    })
    })
    .then(entry => entry.json())
    .then(entry => console.log(entry));

Leave a comment