import { INSTRUCTIONS_URL } from "../../Api/ApiUrls";
import { errorRecord } from "../../common/libEventLog/libCrashlytics/libCrashlyticsEvent";
var UserExperior = require("react-native-userexperior");

// instructions
export const instructionData = async ({ typeId, requestValue }) => {
  const url = `${INSTRUCTIONS_URL}${typeId}?isWebRequest=${requestValue}`;
  UserExperior.startTimer(url);
  console.log("URL >>> ", url);
  try {
    const res = await fetch(url, {
      method: "GET",
    });
    let data = await res.json();
    if (res.status !== 200) {
      throw new Error(data?.error);
    }
    UserExperior.endTimer(url);
    return data;
  } catch (err) {
    errorRecord(err);
  }
};
