Feature Request: convenience methods to get `data` directly from response
See original GitHub issueAdd convenience methods to return data
directly instead of the whole response object
99% of the time I’m using axios, I’m only interested in the data
part of the response, and I need to do destructuring to get it out of the response object. It’d be great if I can use another method that will return data only. This is more useful especially when you want to use another variable name for data
and have to use named destructuring. This can be done by adding corresponding methods that return data only, eg:
axios(config) -> axios.data(config)
axios.request(config) -> axios.requestData(config)
axios.get(url[, config]) -> axios.getData(url[, config])
axios.post(url[, data[, config]]) -> axios.postData(url[, data[, config]])
example for current state:
const { data } = await axios.get(url)
// or
const { data: result } = await axios.get(url)
suggested improvement:
const data = await axios.getData(url)
// or
const result = await axios.getData(url)
P.S. I’d love to help in the implementation if it’s approved
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:10
Top Results From Across the Web
A Guide to Dealing With Customer Feature Requests
Customer feature requests can be difficult to manage. Learn how to better respond to these requests to keep customers happy and improve your ......
Read more >Using the Feature Request Details Page in Savio
The feature request details page has all the information you need to prioritize your features and decide on your product roadmap. Here's how...
Read more >Feature Requests: What are they and how to manage them
Feature requests are a form of product feedback you may frequently ... Here are a few best practices for feature request responses to...
Read more >How SaaS Companies Manage Feature Requests
Learn how SaaS companies manage feature requests, development challenges, and what feature request tracking software they use to keep ...
Read more >Why You Need A Feature Request Tracking System
Convenience – incentivizing feedback, improving response rates. How do your customers leave feedback? Do you force them to look at Trello boards or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t understand why error handling is different for
axios.getData
than it is foraxios.get
. Can you explain with a code example maybe?What about something like Nuxt is doing with $get, $post or $put?
https://axios.nuxtjs.org/usage.html#shortcuts