Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
InvestCustomer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Giang Tran
InvestCustomer
Commits
c3631d0b
Commit
c3631d0b
authored
May 12, 2021
by
Nguyễn Thị Thúy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug timeout
parent
20e8226c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
6 deletions
+36
-6
Profile.js
src/Screens/AccountVerification/Tab/Profile.js
+7
-1
helpers.js
src/apis/helpers.js
+20
-4
PickerAvatart.js
src/components/Picker/PickerAvatart.js
+9
-1
No files found.
src/Screens/AccountVerification/Tab/Profile.js
View file @
c3631d0b
...
...
@@ -106,7 +106,8 @@ const Profile = (props) => {
const
res
=
await
verifyAccountApi
(
data
);
props
.
hideLoading
();
console
.
log
(
res
);
if
(
res
.
data
.
code
==
200
)
{
if
(
res
?.
status
==
200
&&
res
.
data
)
{
if
(
res
.
data
.
code
==
200
)
{
setTimeout
(()
=>
{
props
.
saveUserToRedux
(
res
.
data
.
data
);
Alert
.
alert
(
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
...
...
@@ -118,6 +119,11 @@ const Profile = (props) => {
},
500
);
}
}
else
{
setTimeout
(()
=>
{
Alert
.
alert
(
I18n
.
t
(
'Notification'
),
'upload fail'
);
},
500
);
}
}
else
{
Alert
.
alert
(
I18n
.
t
(
'Notification'
),
I18n
.
t
(
'Please_fill_in'
)
+
titles
[
index
],
...
...
src/apis/helpers.js
View file @
c3631d0b
import
KEY
from
'../assets/AsynStorage'
;
import
axios
from
'axios'
;
import
AsyncStorage
from
'@react-native-community/async-storage'
;
axios
.
defaults
.
timeout
=
10000
;
export
async
function
GetData
(
url
,
data
)
{
const
token
=
await
AsyncStorage
.
getItem
(
KEY
.
TOKEN
);
let
myRequest
=
{
...
...
@@ -31,6 +33,7 @@ export async function GetData(url, data) {
return
err
;
});
}
export
async
function
PostLogin
(
url
,
json
)
{
let
myRequest
=
{
method
:
'post'
,
...
...
@@ -86,6 +89,11 @@ export async function PostData(url, json, isAuth = true) {
export
async
function
PostFormData
(
url
,
data
)
{
const
token
=
await
AsyncStorage
.
getItem
(
KEY
.
TOKEN
);
const
source
=
axios
.
CancelToken
.
source
();
const
timeout
=
setTimeout
(()
=>
{
source
.
cancel
();
// Timeout Logic
},
1000
);
console
.
log
(
token
);
let
myRequest
=
{
method
:
'post'
,
...
...
@@ -95,15 +103,23 @@ export async function PostFormData(url, data) {
'Content-Type'
:
'multipart/form-data'
,
Authorization
:
'Bearer '
+
token
,
},
timeout
:
30
*
1000
,
timeout
:
1000
,
data
:
data
,
cancelToken
:
source
.
token
,
};
console
.
log
(
'post data mobile'
,
myRequest
.
data
);
return
await
axios
(
myRequest
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
{
clearTimeout
(
timeout
);
return
response
;
})
.
then
((
response
)
=>
{
clearTimeout
(
timeout
);
return
response
;
})
.
catch
((
error
)
=>
{
console
.
log
(
error
);
clearTimeout
(
timeout
);
console
.
log
(
'errorTimeout'
,
error
);
const
err
=
{
message
:
'error'
,
status
:
error
.
request
.
status
,
...
...
src/components/Picker/PickerAvatart.js
View file @
c3631d0b
...
...
@@ -63,8 +63,10 @@ const PickerImg = (props) => {
const
res
=
await
changeAvatart
(
createFormData
(
image
,
{
uid
:
props
.
user
.
uid
,
platform
:
Platform
.
OS
}),
);
console
.
log
(
'upload avatar'
,
res
)
props
.
hideLoading
();
if
(
res
.
data
.
code
==
200
)
{
if
(
res
?.
status
==
200
&&
res
.
data
)
{
if
(
res
.
data
.
code
==
200
)
{
setTimeout
(()
=>
{
props
.
saveUserToRedux
(
res
.
data
.
data
);
Alert
.
alert
(
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
...
...
@@ -75,6 +77,12 @@ const PickerImg = (props) => {
Alert
.
alert
(
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
},
500
);
}
}
else
{
setImgAvatart
(
props
.
user
.
picture_url
);
setTimeout
(()
=>
{
Alert
.
alert
(
I18n
.
t
(
'Notification'
),
'upload fail'
);
},
500
);
}
};
const
onchoosGalery
=
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment