X
X
X0lera2018-06-03 06:09:21
JavaScript
X0lera, 2018-06-03 06:09:21

How to get a variable from fetch?

fetch(" api.kai-zer.ru/dev/method/products.getAll ")
.then((r) => r.json())
.then((data) => {
const result = data.response
} )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
webfln, 2018-06-03
@X0lera

What goal are you trying to achieve?
An option is to save the required promise and then extract from it
const fetchResult = fetch("api.kai-zer.ru/dev/method/products.getAll");
fetchResult.then((r) => r.json()).then((data) => { console.log(data.response)})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question