简体   繁体   中英

Axios post form urlencoded requests application/x-www-form-urlencoded

I'm trying to make a requests post with axios, sending that postdata from a checkbox and submit button, but I don't know how to do this correctly with axios, I would appreciate your help `

const URI = "https://www.guadeloupe.gouv.fr/booking/create/12828/0"
    const data = "condition=on&nextButton=Effectuer+une+demande+de+rendez-vous"
    const headers = {
    'Content-Type':           'application/x-www-form-urlencoded',
    'User-Agent':             'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36',
    'Accept-Encoding':        'gzip, deflate, br',
    'Origin':                 'https://www.guadeloupe.gouv.fr'
    }
    
    const resp = await axios.post(URI,data,headers)

with insomnia = INSONMIA POST REQUEST SCREEN SHUT

CHECKBOX = PHOTO CHECKBOX SUBMIT

I can't test with real REST server but I can suggest this code.

It's base on your image and code.

const resp = await axios.post(URI,
            new URLSearchParams({
                'condition': 'condition',
                'nextButton': 'Effectuer une demande de rendez vous' 
            }),
            {
                headers:
                {
                    'Content-Type': 'application/x-www-form-urlencoded'
                }
            })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM