Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[React-Native] [iOS] Middleware stop working when turn off remote debugging #162

Open
cynamon opened this issue Dec 11, 2017 · 5 comments
Open

Comments

@cynamon
Copy link

cynamon commented Dec 11, 2017

This middleware stops working on iOS when remote js debugging is turned off. On android everything is ok.

@nason
Copy link
Collaborator

nason commented Jan 24, 2018

Hi @cynamon can you provide any more detail about this? A sample would be very helpful for us to investigate this issue

@geminiyellow
Copy link

yes, middleware stop working when i use ios simulator.
i tested fetch, it working. is there any sample code for rn?

@zggb
Copy link

zggb commented May 11, 2018

the same for me

import { CALL_API } from 'redux-api-middleware';
const LOGIN_URL = Config.API_URL + '/api/auth/login/';

export function logIn(jsonStringfData) {
  return async(dispatch, getState) => {
    const actionResponse = await dispatch({
      [CALL_API]: {
        types: [ LOGIN_BEGIN,
                 LOGIN_SUCCESS,
                 {
                  type: LOGIN_FAILURE,
                  meta: (action, state, res) => {
                   return {
                     status: res.status,
                     statusText: res.statusText }
                   }
                }
               ],
        endpoint: LOGIN_URL,
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'Accept': 'application/json'
        },
        options: { skipAuthHeader: true },
        body: jsonStringfData
      }
    });
  }
}

export const LOGIN_BEGIN   = 'LOGIN_BEGIN';
export const LOGIN_SUCCESS = 'LOGIN_SUCCESS';
export const LOGIN_FAILURE = 'LOGIN_FAILURE';

export const logInBegin = () => ({
  type: LOGIN_BEGIN
});

export const logInSuccess = (userInfo) => ({
  type: LOGIN_SUCCESS,
  payload: { userInfo }
});

export const logInFailure = error => ({
  type: LOGIN_FAILURE,
  payload: { error }
});

after LOGIN_BEGIN componentWillReceiveProps called and then
LOGIN_SUCCESS or LOGIN_ERROR didn't proceed

but with enabled NETWORK debugger in REACT NATIVE DEBUGGER everything work

(react-native run-android)

also, I found that it works fine with HTTP localhost API requests, and brakes with requests to staging.

UPDATE that was caused by wrong content-security header in be response

@nason
Copy link
Collaborator

nason commented Jun 7, 2018

Sorry, I haven't used this middleware in a react native app, but everything should work as long as there is a global fetch and/or you pass your own custom fetch function.

@zggb your update -- does that mean you have redux-api-middleware working in react native? can you share any details of your setup?

@rawteech
Copy link

Also facing a similar problem on react native iOS.. in my case I can be able to make API calls with Android, but on iOS I get a 401 error("Authentication credentials were not provided.")... and I am 100% sure I have passed in the headers correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants