Question · Angular course · Module 9: HttpClient

Request Immutability

Why do we use req.clone() in an interceptor instead of modifying req directly?

Answer options

  • Because HttpRequest is immutable and you must create a copy with the changes
  • Because clone() sends the request faster
  • Because without clone() the interceptor will not register
  • It is just a convention, you can modify it directly

You can check the correct answer by solving this task in the CodeWorlds game.