Recently I upgraded angular app 13 version to 14 version. I see some of the API calls failing which were working fine in angular 13.
API Call (Angular 13)
domain.com/api/v2/todos/count?filter=created+ge+1997-06-21
API Call (Angular 14)
domain.com/api/v2/todos/count?filter=created%2Bge%2B1997-06-21
"+" symbol replaced with "%2B" causing issue, Is there any way to send + in URL as is?
component.ts
const filter = "created+ge+1997-06-21"
service.todosCount(filter).subscribe()
service.ts
todosCount(params) {
return this.http.get<TodosCount[]>(
'/afes_case_api/v1/cases/state_count',{ params }
)
}
Like figured out in the comment, you intend to send white spaces to the backend. So it's as easy as replacing the
+
character with white spaces:Background
Please check the changelog for Angular 14. In http section, it says:
Servers usually decode + as white space, as white spaces are not supported in URLs. In order to be able to distinguish between the "white space" + and the "real" +, it is common sense to encode the + character to %2B. However it used to be implemented differently by Angular, which has been fixed with v14.