Bird
0
0

Consider this Remix loader function:

medium📝 Predict Output Q4 of 15
Remix - Deployment
Consider this Remix loader function:
export async function loader() {
  const apiEndpoint = process.env.API_ENDPOINT || 'https://default.example.com';
  return { apiEndpoint };
}
If API_ENDPOINT is set to https://api.example.com in your environment, what will apiEndpoint be?
A<code>undefined</code>
B<code>https://api.example.com</code>
C<code>https://default.example.com</code>
DAn error will be thrown
Step-by-Step Solution
Solution:
  1. Step 1: Check environment variable value

    API_ENDPOINT is set to https://api.example.com.
  2. Step 2: Evaluate fallback

    The code uses process.env.API_ENDPOINT || 'https://default.example.com', so since API_ENDPOINT is defined, it will be used.
  3. Final Answer:

    https://api.example.com -> Option B
  4. Quick Check:

    Defined env vars override fallback values [OK]
Quick Trick: Defined env vars override fallback defaults [OK]
Common Mistakes:
MISTAKES
  • Assuming fallback is always used
  • Expecting undefined if env var exists
  • Thinking an error occurs if env var is missing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Remix Quizzes