Reputation: 629
I manage to use axios to do a GET request with header
fetchUsers = ({offset = 1, q = ''} = {}) => new Promise(function (resolve, reject) {
const url = `localhost:3000/users`
axios.get(url, {
headers: { token: 123 }
}).then(response => {
})
})
But I also want optional query param for pagination and search, I do
fetchUsers = ({offset = 1, q = ''} = {}) => new Promise(function (resolve, reject) {
const url = `localhost:3000/users`
axios.get(url, {params: {offset, q}}, {
headers: { token: 123 }
}).then(response => {
})
})
I don't see my token in the header anymore, any clue?
Upvotes: 1
Views: 1768
Reputation: 2188
I think, you should try to move your headers to object with params:
axios.get(url, {params: {offset, q},
headers: { token: 123 }}
Upvotes: 3