Created
September 8, 2019 13:55
-
-
Save gracekrcx/4430cb8df893669b12d25242ec93bf3b to your computer and use it in GitHub Desktop.
apiExample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiExample = ()=>{ | |
const API_URL = '/path'; | |
fetch(API_URL,{ | |
method:'post' | |
headers: { | |
'content-type': 'application/json' | |
}, | |
}).then(function(response){ | |
return response.json() | |
}).then(data=>{ | |
if(data.code == '200'){ | |
// 200 處理邏輯 | |
}else{ | |
// 非 200 處理邏輯 | |
} | |
}).catch(error=>{ | |
// error 處理邏輯 | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment