Advertisement
langbung01

axios get request and return

Sep 5th, 2018
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // return form request api
  2.     checkLOA = async (id) => {
  3.       return new Promise((resolve,reject) => {
  4.         const url = process.env.MIX_BACKEND_IP;
  5.         axios.get(`${url}/api/loa_level/${id}`)
  6.           .then((res) => {
  7.             resolve(res.data.data.loa_level);
  8.           })
  9.           .catch((err) => {
  10.             reject(err);
  11.           });
  12.       });
  13.     }
  14.  
  15.  activateMobile = async (id) => {
  16.       let a;
  17.         try {
  18.              a = await this.checkLOA(this.props.accountInfo.account.id);
  19.         } catch (e) {
  20.             console.log(e)
  21.             a = -1 ;
  22.         }
  23.       if (a >= 1) {
  24.           this.setState({
  25.               mobileId: id,
  26.               openModalConfirmMobile: true,
  27.           });
  28.       } else {
  29.           this.props.dispatch(error({
  30.               title: 'Data not complete.',
  31.               message: 'Please fill in the data and confirming the e-mail before do this.',
  32.           }));
  33.       }
  34.     };
  35.  
  36.  
  37. /*****************************************************************/
  38. //with error header
  39.  
  40. let url = "http://203.154.100.147/api/checkbusiness_owner/"+id_card_value;
  41. axios.get(url,{
  42.     headers:{Authorization:"Bearer "+accessToken}
  43. })
  44.     .then(function (response) {
  45.        
  46.         console.log(response['data']);
  47.     })
  48.     .catch(function (error) {
  49.        
  50.         console.log(error);
  51.     })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement