question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: convenience methods to get `data` directly from response

See original GitHub issue

Add 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:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:10

github_iconTop GitHub Comments

1reaction
Gaafarcommented, May 2, 2020

I don’t understand why error handling is different for axios.getData than it is for axios.get. Can you explain with a code example maybe?

1reaction
LeCoupacommented, Apr 28, 2020

What about something like Nuxt is doing with $get, $post or $put?

https://axios.nuxtjs.org/usage.html#shortcuts

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found