axios POST request with params code example

Example 1: axios pass params

const axios = require('axios');

// Equivalent to `axios.get('https://httpbin.org/get?answer=42')`
const res = await axios.get('https://httpbin.org/get', { params: { answer: 42 } });

res.data.args; // { answer: 42 }

Example 2: how to send data in query param in axios in get request

const res = await axios.get('https://httpbin.org/get', { params: { answer: 42 } });

Example 3: axios library

<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>