Ky: ReferenceError: Property 'Reflect' doesn't exist on ReactNative Android

Created on 4 Dec 2020  路  5Comments  路  Source: sindresorhus/ky

Versions
"ky": 0.25,
"react-native": "0.63.4"

Works fine on iOS

/** Handle the otp generation on forgotPassword */
export const sendOTP = async (email) => {
  try {
    const res = await ky
      .post(`${userAPIURL}/users/forgotPassword`, {
        json: {email: email},
      })
      .json();
    return {success: true, message: 'OTP sent to email'};
  } catch (error) {
    console.log(error);
    const errMsg = await error.response.json();

    // console.log(errMsg);
    return {success: false, message: errMsg.description};
  }
};

Most helpful comment

Personally, I prefer using the in operator instead of Reflect.has(), anyway. I'm fine with changing it if the rest of the team is, too.

All 5 comments

If you have hermes enabled in react native it does not support Reflect.

You will need to polyfill Reflect.has which is the method that ky uses.

I did this using core-js by including import 'core-js/es/reflect/has'; as the first line in my entry file.

The very first paragraph of Ky:

Ky targets modern browsers and Deno.

Personally, I prefer using the in operator instead of Reflect.has(), anyway. I'm fine with changing it if the rest of the team is, too.

I'm +1

Sure

Was this page helpful?
0 / 5 - 0 ratings