← Back to team overview

dhis2-devs team mailing list archive

Regarding api calling(authorization) from internal app


hi All,

I'm building a React app, While calling an api inside the app, it give an
error (Unexpected token < in JSON at position 0). In debugger it shows that
the api url redirected to the login page. Where as i'm already logged in
the system, and install the app in the system.
the code is written below.

componentDidMount() {
.then(response => response.json())
(result) => {
isLoaded: true,
orgUnits: result.organisationUnits
// Note: it's important to handle errors here
// instead of a catch() block so that we don't swallow
// exceptions from actual bugs in components.
(error) => {
isLoaded: true,
 if i use authorisation in header, then it works fine.
Please help me out.

*Shubham Goyal*
Intern, HISP India <https://www.hispindia.org/>
+917508239154 *|* ishubhamgo@xxxxxxxxx