fix: Cookies.set does not stringify JSON (#8807)

* fix: cookie setting

* chore: remove debug statement

* chore: add specs to test stringify
This commit is contained in:
Shivam Mishra
2024-01-29 18:14:49 +05:30
committed by GitHub
parent ef50edb9e2
commit 2eeec22868
3 changed files with 28 additions and 1 deletions

View File

@@ -34,5 +34,12 @@ export const setCookieWithDomain = (
domain: baseDomain,
};
// if type of value is object, stringify it
// this is because js-cookies 3.0 removed builtin json support
// ref: https://github.com/js-cookie/js-cookie/releases/tag/v3.0.0
if (typeof value === 'object') {
value = JSON.stringify(value);
}
Cookies.set(name, value, cookieOptions);
};