Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 處理邏輯
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement