K
K
Konstantin Malyarov2019-07-20 01:39:00
Vue.js
Konstantin Malyarov, 2019-07-20 01:39:00

How to return information received via GET?

filters: {
        period: function (time, close_time) {
            return Math.ceil(Math.abs((new Date(close_time * 1000)).getTime() - (new Date(time * 1000)).getTime()) / (1000 * 3600 * 24));
        },
        price: function (pair) {
            axios.get('https://site.ru/api/binance.php?api=ticket&symbol=' + pair).then(response => {
                return response.data.price;
            })
        }
    }

When filtering, axios does not return data from the request. How to return?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikesol, 2019-07-20
@Mikesol

And where is the check for the presence of the answer as a whole?
What does the api return for this get request?
'Network' in the browser, and select a query, look at its 'preview'.

S
Sergey, 2019-07-20
@Sponom

Try it with async/await

price: async function (pair) {
            var responseData = await axios.get('https://site.ru/api/binance.php?api=ticket&symbol=' + pair)
            return responseData.data.price
        }

Don't forget to check the API response

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question