understanding when to use params and get request axios 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 } });

Tags:

Php Example