|
@@ -48,9 +48,8 @@ function checkAPIError(err) {
|
|
|
*/
|
|
|
|
|
|
const request = async (url, options) => {
|
|
|
- const userinfo = await storage.load({
|
|
|
- key: 'userInfo'
|
|
|
- });
|
|
|
+ const file_uid = await getuid();
|
|
|
+
|
|
|
if (options) {
|
|
|
const method = options.method.toUpperCase();
|
|
|
// switch(method){
|
|
@@ -88,7 +87,7 @@ const request = async (url, options) => {
|
|
|
options.headers = {
|
|
|
Accept: 'application/json',
|
|
|
'Content-Type': 'application/json',
|
|
|
- uid: JSON.parse(userinfo).uid
|
|
|
+ uid: file_uid
|
|
|
// 'token': token? token : null
|
|
|
};
|
|
|
if (method === 'POST' || method === 'PATCH' || method === 'DELETE' || method === 'PUT') {
|
|
@@ -105,4 +104,17 @@ const request = async (url, options) => {
|
|
|
console.log('options', options);
|
|
|
return fetch(url, options).then(checkStatus).then(parseJSON).then(checkAPIDatas).catch(checkAPIError);
|
|
|
};
|
|
|
+async function getuid() {
|
|
|
+ const uid = await storage
|
|
|
+ .load({
|
|
|
+ key: 'userInfo'
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ return '';
|
|
|
+ });
|
|
|
+ if (uid === '') {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ return JSON.parse(uid).uid;
|
|
|
+}
|
|
|
export default request;
|