• Resolved tungneovision

    (@tungneovision)


    Hello friends,

    I am using Nuxt as front-end and WordPress as back-end for CMS purpose. I am creating a form-data like this

    const body = new FormData();

    body.append(“_wpcf7”, “20”);
    body.append(“_wpcf7_version”, “5.9.8”);
    body.append(“_wpcf7_unit_tag”, “wpcf7-f20-o1”);

    and it return 400 code and wpcf7_unit_tag_not_found, There is no valid unit tag. However when I try out with Postman , it works. Because I set auto response email and I receive response on email so it works. the problem is that it only works when I try with Postman or the WordPress theme not from my front-end Nuxt.

    Please help me !!
    I really appreciate any comments.
    Thank you so much in advance !!

Viewing 1 replies (of 1 total)
  • Thread Starter tungneovision

    (@tungneovision)

    More detail about my code :

    this is my custom composable for fetching data purpose

    import { useFetch } from "#app";
    import { useRuntimeConfig } from "#app";

    export default async function useContactFormAPI(body) {
    const runtimeConfig = useRuntimeConfig();
    const { data, error } = await useFetch(runtimeConfig.public.CONTACT_FORM_API, {
    method: "POST",
    headers: {
    "Content-Type": multipart/form-data; charset=utf-8; boundary= + ${Math.random().toString()}
    ,
    },
    body: body,
    });
    console.log(error);
    return data.value;
    }

    this is my event handler

    const handleClick = async (event) =>{
    const body = new FormData();
    ….
    some data
    ….
    body.append(“_wpcf7”, “20”);
    body.append(“_wpcf7_version”, “5.9.8”);
    body.append(“_wpcf7_unit_tag”, “wpcf7-f20-o1”);
    const data = await useContactFormAPI(body);
    console.log(data);
    console.log(event);
    }
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.