File tree Expand file tree Collapse file tree 1 file changed +16
-12
lines changed
Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -21,17 +21,19 @@ export default function useDiff() {
2121
2222 let isCancelled = false
2323
24- if ( isCancelled ) {
25- return
26- }
24+ const fetchDiff = async ( ) => {
25+ if ( isCancelled ) {
26+ return
27+ }
28+
29+ setLoading ( true )
30+ setError ( null )
31+ setData ( null )
2732
28- setLoading ( true )
29- setError ( null )
30- setData ( null )
33+ try {
34+ const res = await fetch ( diffUrl )
35+ const result = await res . json ( )
3136
32- fetch ( diffUrl )
33- . then ( res => res . json ( ) )
34- . then ( result => {
3537 if ( isCancelled ) {
3638 return
3739 }
@@ -44,8 +46,7 @@ export default function useDiff() {
4446 setError ( null )
4547 }
4648 setLoading ( false )
47- } )
48- . catch ( err => {
49+ } catch ( err ) {
4950 if ( isCancelled ) {
5051 return
5152 }
@@ -54,7 +55,10 @@ export default function useDiff() {
5455 setData ( null )
5556 setError ( "We couldn't load the diff right now. Please try again later." )
5657 setLoading ( false )
57- } )
58+ }
59+ }
60+
61+ fetchDiff ( )
5862
5963 return ( ) => {
6064 isCancelled = true
You can’t perform that action at this time.
0 commit comments