Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. apiExample = ()=>{
  2. const API_URL = '/path';
  3. fetch(API_URL,{
  4. method:'post'
  5. headers: {
  6. 'content-type': 'application/json'
  7. },
  8. }).then(function(response){
  9. return response.json()
  10. }).then(data=>{
  11. if(data.code == '200'){
  12. // 200 處理邏輯
  13. }else{
  14. // 非 200 處理邏輯
  15. }
  16. }).catch(error=>{
  17. // error 處理邏輯
  18. })
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement