I am trying to use the vue-select package in my application. I have some code that I copied from the docs and it works fine. However, I would like to convert it to use axios instead of fetch()
for readability and also so I can use my own axios configuration settings.
How can I convert the following code to use axios instead of fetch?
search: debounce((loading, search, vm) => {
fetch(
`https://api.github.com/search/repositories?q=${escape(search)}`
).then((res) => {
res.json().then((json) => (vm.options = json.items))
loading(false)
})
}, 350)
I tried the below code but I got an error: Uncaught (in promise) TypeError: res is not a function
:
search: debounce(async (loading, search, vm) => {
await axios
.get(`https://api.github.com/search/repositories?q=${escape(search)}`)
.then((res) => {
res((json) => (vm.options = json.items))
loading(false)
})
}, 350)