Bird
0
0

What is wrong with this Remix loader code?

medium📝 Debug Q6 of 15
Remix - Performance
What is wrong with this Remix loader code?
export async function loader() {
  return new Response('Hello', {
    headers: { 'Cache-Control': max-age=3600 }
  });
}
ALoader function must return a JSON response, not a Response object
BResponse body must be a JSON object, not a string
CHeaders object should be inside a separate Headers() constructor
Dmax-age=3600 is not a string, it should be quoted
Step-by-Step Solution
Solution:
  1. Step 1: Inspect header value

    The value for 'Cache-Control' must be a string, but max-age=3600 is unquoted.
  2. Step 2: Understand JavaScript syntax

    Without quotes, max-age=3600 is treated as an undefined variable or expression, causing an error.
  3. Step 3: Correct usage

    It should be 'Cache-Control': 'max-age=3600' with quotes around the value.
  4. Final Answer:

    max-age=3600 is not a string, it should be quoted -> Option D
  5. Quick Check:

    Header values must always be strings [OK]
Quick Trick: Cache-Control values must be strings in quotes [OK]
Common Mistakes:
MISTAKES
  • Forgetting to quote header values
  • Misunderstanding Response constructor usage
  • Assuming Response body must be JSON

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Remix Quizzes