SHARE
TWEET

Untitled

a guest Sep 19th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top