codingtcher.com
Theme Night
Home
Login

axios get request with params react

Home » Tutorial Post » axios get request with params react

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 }
Source: masteringjs.io

pass params axios get react

const params = new URLSearchParams([['answer', 42]]);

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

Related Post