Fixed a bug with withcredentials
Set the withCredentials flag as an optional parameter