P
P
pcdesign2019-11-21 09:36:15
React
pcdesign, 2019-11-21 09:36:15

Why is there no access to remote url in react-admin?

I'm trying to get react-admin to log in to a remote server.
Did it like this:

git clone https://github.com/marmelab/react-admin.git && cd react-admin && make install   
make build
make run-demo

Everything is working.
Further into the authProvider.js file I
stuck:
login: ({ username, password }) =>  {
        const request = new Request('https://mydomain.com/authenticate', {
            method: 'POST',
            body: JSON.stringify({ username, password }),
            headers: new Headers({ 'Content-Type': 'application/json' }),
        });
        return fetch(request)
            .then(response => {
                if (response.status < 200 || response.status >= 300) {
                    throw new Error(response.statusText);
                }
                return response.json();
            })
            .then(({ token }) => {
                localStorage.setItem('token', token);
            });
    },
// ...

And then I look in the logs on my remote server https://mydomain.com/authenticate - there is complete silence.
No attempts and no requests. And in console writes:
Uncaught Error: No fallback response defined for GET to [object Request]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Alexandrovich, 2019-11-21
@pcdesign

the simplest option try through a simple fetch or axios

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question