Как получить данные с API в React native?

В общем, написал простое API на php, которое выводит список товаров в json формате.

Ниже пример запроса:

http://i29882nm.beget.tech/api/product/read.php

В самом проекте пытаюсь получить данные таким образом:

componentDidMount(){

    fetch('http://i29882nm.beget.tech/api/product/read.php')
        .then(response => response.text())
        .then((responseJson)=> {
            console.log(responseJson);
        })
        .catch(error=>console.log(error))
}

Однако в консоли вижу следующее:

<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx-reuseport/1.13.4</center>
</body>
</html>

Возможно все дело в заголовках. Но тогда какие именно указывать?


Ответы (0 шт):