提交 8ebaf646 authored 作者: vipcxj's avatar vipcxj

1.优化错误返回

2.尝试解决重复cookie
上级 6cb8409a
......@@ -10,7 +10,7 @@ export function setCookie(name, value, options = {}) {
if (name) {
const expireSet = expires ? ` expires=${moment().add(expires, 'ms').toDate().toUTCString()};` : '';
const domainSet = domain ? ` domain=${domain};` : '';
const pathSet = path ? ` path=${path};` : '';
const pathSet = path ? ` path=${path};` : ' path=/';
const valueSet = value ? `${name}=${encodeURIComponent(value)};` : '';
document.cookie = `${valueSet}${expireSet}${domainSet};${pathSet}`; // eslint-disable-line
}
......@@ -33,7 +33,7 @@ export function getCookie(name) {
export function delCookie(name, { domain, path } = {}) {
if (getCookie(name)) {
const domainSet = domain ? ` domain=${domain};` : '';
const pathSet = path ? ` path=${path};` : '';
const pathSet = path ? ` path=${path};` : ' path=/';
document.cookie = `${name}=; expires=Thu, 01-Jan-70 00:00:01 GMT;${pathSet}${domainSet}`; // eslint-disable-line
}
}
......
......@@ -38,7 +38,9 @@ const parseResponse = (response) => {
if (errorCode === 0) {
return data;
} else {
throw new Error(message || data);
const error = new Error(message || data);
error.data = response;
throw error;
}
};
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论