Best JavaScript code snippet using qawolf
main.js
Source:main.js
1import axios from 'axios';2import qs from 'qs';3axios.defaults.validateStatus=(status)=>{4 if (status === 401) {//没ç»é5 localStorage.removeItem('role');6 localStorage.removeItem('zlfuserInfo');7 window.location.href='/home.html';8 return false;9 } else {10 return true11 };12}13var TIME_OUT=50000;14var zlf_base_prefix15if(__DEV__){16 zlf_base_prefix = 1?'https://api.zulifangs.com':'http://redliam.51vip.biz:20095/api-zlf';//'http://hjj1.tunnel.echomod.cn/api-zlf';17}else if(__PROD__){18 zlf_base_prefix='https://api.zucube.cn';19}20const base_axios_options = {21 withCredentials:true,22 // timeout:TIME_OUT,23 headers: { 'Content-Type': 'application/json' }24};25const customer_base = `${zlf_base_prefix}`;26const customerAxios = axios.create(Object.assign({}, { baseURL: `${customer_base}`}, base_axios_options));27export const customerModule={28 //æ°é»å表29 getNewsList:params => { return customerAxios.get('/article/getByPage', {params:params}).then(res => res.data); },30 //æ°é»è¯¦æ
31 getNewsDetail:params => { return customerAxios.get('/article/getArticleDetail', {params:params}).then(res => res.data); },32 //客æ·æ³¨åæ¥å£33 registerCustorm:params => { return customerAxios.post('/customers/register', params).then(res => res.data); },34 //æ£éªå
¬å¸ååæ¯å¦æ³¨å35 checkInfo:params => { return customerAxios.post('/user/checkInfo', params).then(res => res.data); },36 //è·åéªè¯ç 37 getVerification:params => { return customerAxios.get('/verification', {params:params}).then(res => res.data); },38 //éæ°ç»å®é®ç®±æ¶ è·åéªè¯ç 39 verificationMail:params => { return customerAxios.get('/verificationMail', {params:params}).then(res => res.data); },40 //ä¿®æ¹å¯ç è·åéªè¯ç 41 verificationPass:params => { return customerAxios.get('/verificationPass', {params:params}).then(res => res.data); },42 //ç»å®é®ç®±æ¥å£43 changeMail:params => { return customerAxios.get('/changeMail', {params:params}).then(res => res.data); },44 //ä¿å客æ·ä¿¡æ¯è系人45 saveOrderCustomerInfo:params => { return customerAxios.post('/user/perfectUser', params).then(res => res.data); },46 //ç§èµæµç®ä½éª47 calculation:params => { return customerAxios.post('/calcul/calculation', params).then(res => res.data); },48 //客æ·æ°å»ºé¡¹ç®49 saveCustomerItem:params => { return customerAxios.post('/customers/save', params).then(res => res.data); },50 //è·åææ项ç®51 getOrderInfoList:params => { return customerAxios.get('/customers/getOrderInfoList').then(res => res.data); },52 //è·åç§èµæå¡53 getRentService:params => { return customerAxios.get('/customers/getNewProjectMenu', {params:params}).then(res => res.data); },54 //ä¿å项ç®è系人55 saveProjectPersonInfo:params => { return customerAxios.post('/customers/saveOrderCustomerInfo', params).then(res => res.data); },56 //è·å项ç®è系人57 getOrderCustomerInfo:params => { return customerAxios.get('/customers/getOrderCustomerInfo', {params:params}).then(res => res.data); },58 //è·åç§èµç©59 getLease:params => { return customerAxios.get('/getLease', {params:params}).then(res => res.data); },60 //ä¿åä¾åºåè系人æ¥å£61 changeSupplierUser:params => { return customerAxios.post('/supplier/changeUser', params).then(res => res.data); },62 //ä¿å产åæ¸
å63 saveProductComm:params => { return customerAxios.post('/customers/saveProductComm', params).then(res => res.data); },64 //è·å项ç®è¯¦æ
65 getProjectInfo:params => { return customerAxios.get('/customers/getProjectInfo', {params:params}).then(res => res.data); },66 //è·åæå®ä¾åºåä¿¡æ¯67 getAppointSupplier:params => { return customerAxios.get('/customers/getAppointSupplier', {params:params}).then(res => res.data); },68 //è·åæ¨èä¾åºå69 getRecommendSupplier:params => { return customerAxios.get('/customers/getRecommendSupplier', {params:params}).then(res => res.data); },70 //è·åæå®åä½ä¾åºå产åå表71 getAppointProgress:params => { return customerAxios.get('/customers/getAppointProgress', {params:params}).then(res => res.data); },72 //è·åæ¨èä¾åºå产åå表73 getRecommendProgress:params => { return customerAxios.get('/customers/getRecommendProgress', {params:params}).then(res => res.data); },74 //è·åååä¸ä»æ¬¾75 getContractAndPay:params => { return customerAxios.get('/customers/getContractAndPay', {params:params}).then(res => res.data); },76 //è·å客æ·ååå表77 getCustomerstMainLease:params => { return customerAxios.get('/customers/getMainLease', {params:params}).then(res => res.data); },78 //è·å客æ·åå详æ
79 getMainLeaseDetail:params => { return customerAxios.get('/customers/getMainLeaseDetail', {params:params}).then(res => res.data); },80 //ä¿åéªæ¶ä¿¡æ¯81 acceptance:params => { return customerAxios.post('/customers/acceptance', params).then(res => res.data); },82 //è·åéªæ¶ä¿¡æ¯83 getAcceptanceVO:params => { return customerAxios.get('/customers/getAcceptanceVO', {params:params}).then(res => res.data); },84 //ä¾åºå注å85 registerSupplier:params => { return customerAxios.post('/supplier/register', params).then(res => res.data); },86 //ç»å½æ¥å£87 login:params => { return customerAxios.post('/login?'+ qs.stringify(params)).then(res => res.data); },88 //éåºç»éæ¥å£89 logout:params => { return customerAxios.post('/logout').then(res => res.data); },90 //ä¸ä¼ æ¥å£ 91 upload:params => { return customerAxios.post('/updateContent', params).then(res => res.data); },92 //å¤æ件ä¸ä¼ 93 mulUploadFile:params => { return customerAxios.post('/mulUploadFile', params).then(res => res.data); },94 //è·åå¸åºå®¢æ·ç»é人信æ¯95 getCurrentUser:params => { return customerAxios.post('/getUser').then(res => res.data); },96 //è·åä¾åºåç»é人信æ¯97 getSupplierUser:params => { return customerAxios.get('/supplier/getUser').then(res => res.data); },98 //è·åä¾åºåèµæ99 getDatum:params => { return customerAxios.get('/supplier/getDatum').then(res => res.data); },100 //è·åä¾åºåæ©å±ä¿¡æ¯101 getExtSupplier:params => { return customerAxios.get('/supplier/getExtSupplier').then(res => res.data); },102 //æ¨èå¼å¼å
³103 openRecom:params => { return customerAxios.get('/supplier/openRecom', {params:params}).then(res => res.data); },104 //è·åæ¨èå¼105 getRecommResult:params => { return customerAxios.get('/supplier/getRecommResult').then(res => res.data); },106 //ä¿åæ¨è详æ
107 saveRecommend:params => { return customerAxios.post('/supplier/saveRecommend', params).then(res => res.data); },108 //è·åæ¨è详æ
109 getRecommend:params => { return customerAxios.get('/supplier/getRecommend', {params:params}).then(res => res.data); },110 //è·å交æä¸å¿å表111 getRecommDetail:params => { return customerAxios.get('/supplier/getRecommDetail', {params:params}).then(res => res.data); },112 //è·å项ç®å®¢æ·ä¿¡æ¯113 getCustomerContact:params => { return customerAxios.get('/supplier/getCustomerContact', {params:params}).then(res => res.data); },114 //è·å项ç®å¤§å®¢æ·ä»£è¡¨115 getPlatformContact:params => { return customerAxios.get('/supplier/getPlatformContact', {params:params}).then(res => res.data); },116 //ä¿åååè¿åº¦117 saveContract:params => { return customerAxios.post('/supplier/saveContract', params).then(res => res.data); },118 //è·åååè¿åº¦è¯¦æ
119 getContractProgress:params => { return customerAxios.get('/supplier/getContractProgress', {params:params}).then(res => res.data); },120 //è·åååå表121 getMainLease:params => { return customerAxios.get('/supplier/getMainLease', {params:params}).then(res => res.data); },122 //è·åéªæ¶å®ææ¥å£123 getSupplierAcceptanceVO:params => { return customerAxios.get('/supplier/getAcceptanceVO', {params:params}).then(res => res.data); },124 //ä¿åä¾åºåå®å对æ¥äººä¿¡æ¯125 saveAfterSaleMan:params => { return customerAxios.post('/supplier/saveAfterSaleMan', params).then(res => res.data); },126 //è·åä¾åºåå®å对æ¥äººä¿¡æ¯127 getAfterSaleMan:params => { return customerAxios.get('/supplier/getAfterSaleMan', {params:params}).then(res => res.data); },128 //è·å交æè¿å±æ¥å£129 getProductListComm:params => { return customerAxios.get('/supplier/getProductListComm', {params:params}).then(res => res.data); },130 //è·å客æ·è系人信æ¯131 getCustomerContact:params => { return customerAxios.get('/supplier/getCustomerContact', {params:params}).then(res => res.data); },132 //é请ç 133 relationOrder:params => { return customerAxios.get('/supplier/relationOrder', {params:params}).then(res => res.data); },134 //è·åæ¶æ¯æ¥å£135 getMsg:params => { return customerAxios.get('/msg/getMsg', {params:params}).then(res => res.data); },136 getMsgDetail:params => { return customerAxios.get('/msg/getMsgDetail', {params:params}).then(res => res.data); },137 getNotReadNum:params => { return customerAxios.get('/msg/getNotReadNum', {params:params}).then(res => res.data); },138 //æ¾åå¯ç 139 changePwd:params => { return customerAxios.post('/changePwd?'+ qs.stringify(params)).then(res => res.data); },140 //è·åè¥ä¸æ§ç
§å®¡æ ¸ç¶æ141 getLicenseStatus:params => { return customerAxios.get('/getLicenseStatus', {params:params}).then(res => res.data); },142 //æ£éªéªè¯ç çç¶æ143 checkVerificationCode:params => { return customerAxios.get('/checkVerificationCode', {params:params}).then(res => res.data); },144 //è·åéªåçç¶æ145 factoryInspection:params => { return customerAxios.get('/factoryInspection').then(res => res.data); },146 //æ ¡éªé请ç 147 checkInvitation:params => { return customerAxios.get('/supplier/checkInvitation', {params:params}).then(res => res.data); },148}149export const multipleAxios=(postArray,cb)=>{150 return axios.all(postArray).then(axios.spread(function(){151 cb(...arguments);152 }));153}154customerAxios.interceptors.response.use( (response)=> {155 // 对ååºæ°æ®åç¹ä»ä¹156 if(response.data.statusCode=='401'){157 localStorage.removeItem('role');158 localStorage.removeItem('zlfuserInfo');159 window.location.href='/home.html';160 }161 return response;162 }, (error)=>{163 // 对ååºé误åç¹ä»ä¹164 return Promise.reject(error);...
getData.js
Source:getData.js
...4axios.defaults.withCredentials = true;5/**6 * 1ãç¨æ·èº«ä»½æ¥è¯¢æ¥å£7 */8export const getUserId = (params) => axios.get(domain+'/newMemberCenter/user/getUserIdentity',{9 params:params10 })11 .then(function(response) {12 return response.data13 });14/**15 * 2ãæ ¡åç¨æ·èº«ä»½æ¥è¯¢æ¥å£16 */17export const getUserCampusId = (params) => axios.get(domain+'/newMemberCenter/user/getUserCampusIdentity',{18 params:params19}).then(function(response) {20 return response.data21});22/**23 * 3ãç¨æ·ä¿¡æ¯æ¥è¯¢æ¥å£24 */25export const getUserInfo = (params) => axios.get(domain+'/newMemberCenter/user/getUserInfo',{26 params:params27}).then(function(response) {28 return response.data29});30/**31 * 4ãéå¸æ°éæ¥è¯¢æ¥å£32 */33export const getGoldCoinCount = (params) => axios.get(domain+'/newMemberCenter/getGoldCoinCount',{34 params:params35}).then(function(response) {36 return response.data37});38/**39 * 5ãé¢éæ°éæ¥è¯¢æ¥å£40 */41export const getGBCount = (params) => axios.get(domain+'/newMemberCenter/getGBCount',{42 params:params43}).then(function(response) {44 return response.data45});46/**47 * 6ãå¡å¸æ°éæ¥è¯¢æ¥å£48 */49export const getCouponCount = (params) => axios.get(domain+'/newMemberCenter/getCouponCount',{50 params:params51}).then(function(response) {52 return response.data53});54/**55 * 7ãUPææ°æ¥è¯¢æ¥å£56 */57export const queryMemberGradeValue = (params) => axios.get(domain+'/newMemberCenter/queryMemberGradeValue',{58 params:params59}).then(function(response) {60 return response.data61});62/**63 * 8ãä¼åæçPMæ¥è¯¢æ¥å£64 */65export const getMemberRightsPM = (params) => axios.get(domain+'/newMemberCenter/getMemberRightsPM',{66 params:params67}).then(function(response) {68 return response.data69});70/**71 * 9ãä¼å头é¨å¹¿åä½PMæ¥è¯¢æ¥å£72 */73export const getMemberHeadADPM = (params) => axios.get(domain+'/newMemberCenter/getMemberHeadADPM',{74 params:params75}).then(function(response) {76 return response.data77});78/**79 * 10ãæ ¡åç²¾å广åä½PMæ¥è¯¢æ¥å£80 */81export const getCampusADPM = (params) => axios.get(domain+'/newMemberCenter/getCampusADPM',{82 params:params83}).then(function(response) {84 return response.data85});86/**87 * 11ãä¼åä¼é广åä½PMæ¥è¯¢æ¥å£88 */89export const getMemberPreferencePM = (params) => axios.get(domain+'/newMemberCenter/getMemberPreferencePM',{90 params:params91}).then(function(response) {92 return response.data93});94/**95 * 12ãä¸å±UP计å广åä½æ¥è¯¢æ¥å£96 */97export const getExclusiveUpPlanPM = (params) => axios.get(domain+'/newMemberCenter/getExclusiveUpPlanPM',{98 params:params99}).then(function(response) {100 return response.data101});102/**103 * 13.1æ¥è¯¢ä»»å¡å表104 */105export const queryMission = (params) => axios.get(domain+'/newMemberCenter/mission/queryMission',{106 params:params107}).then(function(response) {108 return response.data109});110/**111 * 13.2æ¥è¯¢ä»»å¡è¯¦æ
112 */113export const queryMissionDetail = (params) => axios.get(domain+'/newMemberCenter/mission/queryMissionDetail',{114 params:params115}).then(function(response) {116 return response.data117});118/**119 * 13.3æ¥åä»»å¡120 */121export const receiveMission = (params) => axios.get(domain+'/newMemberCenter/mission/receiveMission',{122 params:params123}).then(function(response) {124 return response.data125});126/**127 * 13.4é¢åä»»å¡å¥å±128 */129export const rewardMission = (params) => axios.get(domain+'/newMemberCenter/mission/rewardMission',{130 params:params131}).then(function(response) {132 return response.data133});134/**135 * 14.1 æ¥è¯¢éå¸å¤ºå®æ´»å¨å表信æ¯136 */137export const queryActivityList = (params) => axios.get(domain+'/newMemberCenter/queryActivityList',{138 params:params139}).then(function(response) {140 return response.data141});142/**143 * 14.2 æ¥è¯¢éå¸å¤ºå®æ´»å¨è¯¦æ
ä¿¡æ¯144 */145export const queryActivityDetail = (params) => axios.get(domain+'/newMemberCenter/queryActivityDetail',{146 params:params147}).then(function(response) {148 return response.data149});150/**151 * 14.3 ç¨æ·ä¸ååå¼¹çªæ¥å£è¯·æ±å°å152 */153export const queryBasicInfoPreOrder = (params) => axios.get(domain+'/newMemberCenter/activity/queryBasicInfoPreOrder',{154 params:params155}).then(function(response) {156 return response.data157});158/**159 * 14.4 æ°å¢æ追å éå¸å¤ºå®æ¥å£è¯·æ±å°å160 */161export const createOrRebuyOrder = (params) => axios.get(domain+'/newMemberCenter/activity/createOrRebuyOrder',{162 params:params163}).then(function(response) {164 return response.data165});166/**167 * 15.1 å¯ç¨å
æ¢ååå表168 */169export const queryExchangeGoods = (params) => axios.get(domain+'/newMemberCenter/queryExchangeGoods',{170 params:params171}).then(function(response) {172 return response.data173});174/**175 * 15.2 æ¥è¯¢åå详æ
176 */177export const queryExchangeGoodDetail = (params) => axios.get(domain+'/newMemberCenter/queryExchangeGoodDetail',{178 params:params179}).then(function(response) {180 return response.data181});182/**183 * 15.3 éªè¯ååæ¯å¦å¯å
æ¢184 */185export const checkExchangeGood = (params) => axios.get(domain+'/newMemberCenter/checkExchangeGood',{186 params:params187}).then(function(response) {188 return response.data189});190/**191 * 15.4 ååå
æ¢192 */193export const exchange = (params) => axios.get(domain+'/newMemberCenter/exchange',{194 params:params195}).then(function(response) {196 return response.data197});198/**199 * 16 æ¥è¯¢ééè¿ç°æªé¢åæ¥å£200 */201export const queryPlatinumRebateRightsInfo = (params) => axios.get(domain+'/newMemberCenter/queryPlatinumRebateRightsInfo',{202 params:params203}).then(function(response) {204 return response.data205});206/**207 * 17 æ¿æ´»é»é身份208 */209export const ActivateBlack = (params) => axios.get('//vip.jr.jd.com/jsonp/jsonpActivateBlack',{210 params:params211}).then(function(response) {212 return response.data...
UserApi.js
Source:UserApi.js
...4 static loginUser(user) {5 return axios.post(`${API_BASE}/api/user/login`, user);6 }7 static getCurrentUser() {8 return axios.get(`${API_BASE}/api/user`,{withCredentials:true});9 }10 static logoutUser(user) {11 return axios.post(`${API_BASE}/api/restaurant/search`, {12 username:user.email,13 password:user.password14 });15 }16 static signUpUser(user) {17 return axios.post(`${API_BASE}/api/user/register`, user);18 }19 static createMyAddress(address, userId) {20 return axios.post(`${API_BASE}/api/user/${userId}/address/create`, address);21 }22 static updateMyAddress(address,userId) {23 return axios.post(`${API_BASE}/api/user/${userId}/address/update`, address);24 }25 static createMyPhone(phone,userId) {26 return axios.post(`${API_BASE}/api/user/${userId}/phone/create`, phone);27 }28 static updateMyPhone(phone,userId) {29 return axios.post(`${API_BASE}/api/user/${userId}/phone/update`, phone);30 }31 static getRestaurantsForManagerSignup() {32 return axios.get(`${API_BASE}/api/user/restaurants/unmanaged`);33 }34 static getRestaurantsForOwnerSignup() {35 return axios.get(`${API_BASE}/api/restaurant/db/lazy`);36 }37 // Manager page38 static getRestaurantDetailsForManager(managerId) {39 return axios.get(`${API_BASE}/api/user/${managerId}/restaurant`);40 }41 static getPendingOrdersForManager(managerId) {42 return axios.get(`${API_BASE}/api/user/${managerId}/restaurant/orders/pending`);43 }44 static getAllOrdersForManager(managerId) {45 return axios.get(`${API_BASE}/api/user/${managerId}/restaurant/orders`);46 }47 static getAvailableDeliveryBoys() {48 return axios.get(`${API_BASE}/api/user/deliveryBoys`);49 }50 static assignOrderToDeliveryBoy(deliveryBoyId,orderId) {51 return axios.get(`${API_BASE}/api/user/deliveryBoy/${deliveryBoyId}/${orderId}`);52 }53 static getDeliveryBoyAssignedOrders(deliveryBoyId) {54 return axios.get(`${API_BASE}/api/user/deliveryBoy/order/${deliveryBoyId}`);55 }56 static getOrderAssignedToMe(deliveryBoyId) {57 return axios.get(`${API_BASE}/api/user/${deliveryBoyId}/order`);58 }59 static markOrderAsDelivered(orderId) {60 return axios.get(`${API_BASE}/api/restaurant/order/deliver/${orderId}`);61 }62 static deleteAddress(userId,addressId) {63 return axios.get(`${API_BASE}/api/user/${userId}/address/${addressId}/delete`);64 }65 static deletePhone(userId,phoneId) {66 return axios.get(`${API_BASE}/api/user/${userId}/phone/${phoneId}/delete`);67 }68 static updateMyProfile(user) {69 return axios.post(`${API_BASE}/api/user/profile/update`,user);70 }71 // Admin72 static getAllUsers() {73 return axios.get(`${API_BASE}/api/admin/users`);74 }75 static getAllRestaurants() {76 return axios.get(`${API_BASE}/api/restaurant/db/lazy`);77 }78 static getOwnerRestaurants(ownerId) {79 return axios.get(`${API_BASE}/api/user/owner/restaurants/${ownerId}`);80 }81 static getAllApprovals() {82 return axios.get(`${API_BASE}/api/admin/approvals/pending`);83 }84 static deleteUser(userId) {85 return axios.get(`${API_BASE}/api/admin/user/delete/${userId}`);86 }87 static getSelectedUserDetails(userId) {88 return axios.get(`${API_BASE}/api/user/details/${userId}`);89 }90 // menu item CRUD91 static createMenuItem(menuItem, menuId) {92 return axios.post(`${API_BASE}/api/admin/item/create/${menuId}`, menuItem);93 }94 static updateMenuItem(menuItem) {95 return axios.post(`${API_BASE}/api/admin/item/update`, menuItem);96 }97 static deleteMenuItem(menuItemId) {98 return axios.get(`${API_BASE}/api/admin/item/delete/${menuItemId}`);99 }100 static approveOwnership(ownerId, restaurantKey) {101 return axios.get(`${API_BASE}/api/admin/approval/approve/${ownerId}/${restaurantKey}`);102 }103 static rejectOwnership(ownerId, restaurantKey) {104 return axios.get(`${API_BASE}/api/admin/approval/reject/${ownerId}/${restaurantKey}`);105 }106 static deleteRestaurant(restaurantKey) {107 return axios.get(`${API_BASE}/api/admin/restaurant/delete/${restaurantKey}`);108 }109 static requestOwnerShip(ownerId, restaurantKey) {110 return axios.get(`${API_BASE}/api/user/${ownerId}/own/restaurant/${restaurantKey}`);111 }112 static unAssignOwnership(ownerId, restaurantKey) {113 return axios.get(`${API_BASE}/api/user/owner/unassign/${ownerId}/${restaurantKey}`);114 }115 static getUnOwnedRestaurants(ownerId) {116 return axios.get(`${API_BASE}/api/user/restaurants/unowned/${ownerId}`);117 }118 // Followers119 static getIamFollowing(userId) {120 return axios.get(`${API_BASE}/api/user/followings/${userId}`);121 }122 static followCustomer(userId, toBeFollowedId) {123 return axios.get(`${API_BASE}/api/user/follow/${userId}/${toBeFollowedId}`);124 }125 static unfollowCustomer(userId, toBeUnFollowedId) {126 return axios.get(`${API_BASE}/api/user/unfollow/${userId}/${toBeUnFollowedId}`);127 }128 static getMyListOfOrders(userId) {129 return axios.get(`${API_BASE}/api/user/order/${userId}`);130 }131 static adminCreateUser(user) {132 return axios.post(`${API_BASE}/api/admin/user/create`, user);133 }134}...
store.js
Source:store.js
...12 },13 actions: {14 // eslint-disable-next-line15 getKhg({}){16 return axios.get(`${M_API}/costByActivity`)17 .then(res => {18 return res.data19 })20 // .catch(err => Promise.reject(err))21 },22 getAnggaran({ }){23 return axios.get(`${M_API}/anggaran`)24 .then(res => {25 return res.data26 })27 },28 provinces({ }) {29 return axios.get(`${M_API}/provinces`)30 .then(res => {31 return res.data32 })33 },34 getPlanningAnggaran({ }) {35 return axios.get(`${M_API}/peatlandrewetting`)36 .then(res => {37 return res.data38 })39 40 },41 getPlanningrevegetasi({ }) {42 return axios.get(`${M_API}/revegetation`)43 .then(res => {44 return res.data45 })46 47 },48 getPlanningrevitalization({ }) {49 return axios.get(`${M_API}/revitalization`)50 .then(res => {51 return res.data52 })53 54 },55 56 getPlanningStabilization({ }) {57 return axios.get(`${M_API}/baseStabilization`)58 .then(res => {59 return res.data60 })61 62 },63 getPlanninginstStrengthening({ }) {64 return axios.get(`${M_API}/instStrengthening`)65 .then(res => {66 return res.data67 })68 69 },70 getPlanningcoopImprove({ }) {71 return axios.get(`${M_API}/coopImprove`)72 .then(res => {73 return res.data74 })75 76 },77 getPlanningactifRoles({ }) {78 return axios.get(`${M_API}/actifRoles`)79 .then(res => {80 return res.data81 })82 83 },84 getPlanningpeatlandRestoration({ }) {85 return axios.get(`${M_API}/peatlandRestoration`)86 .then(res => {87 return res.data88 })89 90 },91 getPlanningadminstrartionManagement({ }) {92 return axios.get(`${M_API}/administrationManagement`)93 .then(res => {94 return res.data95 })96 97 },98 // eslint-disable-next-line99 getPlanningCost({ }) {100 return axios.get(`${M_API}/totalcost`)101 .then(res => {102 return res.data103 })104 .catch(err => Promise.reject(err))105 },106 totalkegiatan({ }) {107 return axios.get(`${M_API}/totalkegiatan`)108 .then(res => {109 return res.data110 })111 .catch(err => Promise.reject(err))112 },113 114 totallembaga({ }) {115 return axios.get(`${M_API}/totallembaga`)116 .then(res => {117 return res.data118 })119 .catch(err => Promise.reject(err))120 },121 // eslint-disable-next-line122 getPlanningCostByProvince({ }) {123 return axios.get(`${M_API}/costByProvince`)124 .then(res => {125 return res.data126 })127 .catch(err => Promise.reject(err))128 },129 // eslint-disable-next-line130 getPlanningCostByKegiatan({ }) {131 return axios.get(`${M_API}/costByActivity`)132 .then(res => {133 return res.data134 })135 .catch(err => Promise.reject(err))136 },137 // eslint-disable-next-line138 getPlanningAreaByProvince({ }) {139 return axios.get(`${M_API}/area-by-province-plan`)140 .then(res => {141 return res.data142 })143 .catch(err => Promise.reject(err))144 },145 // eslint-disable-next-line146 getPlanningAction({ }) {147 return axios.get(`${M_API}/total-action-plan`)148 .then(res => {149 return res.data150 })151 .catch(err => Promise.reject(err))152 },153 // eslint-disable-next-line154 getPlanningActionByProvince({ }) {155 return axios.get(`${M_API}/action-by-province-plan`)156 .then(res => {157 return res.data158 })159 .catch(err => Promise.reject(err))160 },161 // eslint-disable-next-line162 getPlanningCostByFundingSource({ }) {163 return axios.get(`${M_API}/cost-by-funding-source-plan`)164 .then(res => {165 return res.data166 })167 .catch(err => Promise.reject(err))168 },169 }170}...
api.js
Source:api.js
...22export const requestLogin = params => {23 return axios.post(`${base}/user/login`, params).then(res => res.data);24};25export const getFlyerJobListPage = params => {26 return axios.get(`${base}/flyerJob/listpage`, {params: params});27};28export const removeFlyerJob = params => {29 return axios.get(`${base}/flyerjob/remove`, {params: params});30};31export const operateFlyerJob = params => {32 return axios.get(`${base}/flyerjob/operate`, {params: params});33};34export const runFlyerJobNow = params => {35 return axios.get(`${base}/flyerjob/runnow`, {params: params});36};37export const cancelFlyerJobNow = params => {38 return axios.get(`${base}/flyerjob/cancel`, {params: params});39};40export const batchRemoveFlyerJob = params => {41 return axios.get(`${base}/flyerjob/batchremove`, {params: params});42};43export const editFlyerJob = params => {44 return axios.post(`${base}/flyerjob/edit`, params);45};46export const addFlyerJob = params => {47 return axios.get(`${base}/flyerjob/add`, {params: params});48};49export const listClient = params => {50 return axios.get(`${base}/flyerjob/clients`, {params: params});51};52//record53export const listRecord = params => {54 return axios.get(`${base}/record/list`, {params: params});55};56// app57export const getAppListPage = params => {58 return axios.get(`${base}/app/listpage`, {params: params});59};60export const getAppList = params => {61 return axios.get(`${base}/app/list`);62};63export const addApp = params => {64 return axios.get(`${base}/app/add`, {params: params});65};66export const editApp = params => {67 return axios.post(`${base}/app/edit`, params);68};69export const removeApp = params => {70 return axios.get(`${base}/app/remove`, {params: params});71};72export const batchRemoveApp = params => {73 return axios.get(`${base}/app/batchremove`, {params: params});74};75// user76export const getUserListPage = params => {77 return axios.get(`${base}/user/listpage`, {params: params});78};79export const getUserList = params => {80 return axios.get(`${base}/user/list`);81};82export const addUser = params => {83 return axios.get(`${base}/user/add`, {params: params});84};85export const editUser = params => {86 return axios.post(`${base}/user/edit`, params);87};88export const removeUser = params => {89 return axios.get(`${base}/user/remove`, {params: params});90};91//cluster92export const getCluster = params => {93 return axios.get(`${base}/cluster/show`);94};95export const editCluster = params => {96 return axios.get(`${base}/cluster/save`, {params: params});...
spotifyRequest.test.js
Source:spotifyRequest.test.js
1const axios = require ('axios');2jest.mock('../database/users.js');3jest.mock('axios')4jest.mock('../spotify/spotifyRequest.js');5process.env.CLIENT_ID = "client_id_mock"6process.env.CLIENT_SECRET = "client_secret_mock"7process.env.SPOTIFY_REDIRECT = "SPOTIFY_REDIRECT_mock"8const spotifyRequest = require ('../spotify/spotifyRequest');9const {10 getFromSpotifyWithLimits,11 getFromSpotify,12 getFromSpotifyByIds13} = jest.requireActual('../spotify/spotifyRequest');14describe('module spotifyRequest', () => {15 beforeEach(() => {16 jest.resetAllMocks('axios')17 })18 describe('function getFromSpotify', () => {19 it('should call axios.get', () => {20 return getFromSpotify('some random url', 'random token')21 .then(results => {22 expect(axios.get).toHaveBeenCalledTimes(1);23 })24 })25 it('should have called axios.get with arguments', () => {26 const args = {27 url: 'urlArg',28 token: 'tokenArg',29 options: {30 params: {31 }32 }33 }34 const request = getFromSpotify(args.url, args.token, args.options);35 return request.then (results => {36 expect(axios.get).toHaveBeenCalledWith(args.url, expect.any(Object))37 })38 })39 it('should have returned a promise', () => {40 expect(getFromSpotify()).toBeInstanceOf(Promise);41 })42 it('should return data property from axios.get', () => {43 const mockedData = {44 arg1: 'test1',45 arg2: 'test2'46 }47 axios.get.mockReturnValueOnce(Promise.resolve({data: mockedData}))48 return getFromSpotify('someUrl', 'token')49 .then(data => {50 expect(data).toStrictEqual(mockedData);51 expect(data).toStrictEqual(expect.objectContaining({52 arg1: 'test1',53 arg2: 'test2'54 }))55 })56 })57 })58 describe('function getFromSpotifyWithLimits', () => {59 it('should return a promise', () => {60 expect(getFromSpotifyWithLimits()).toBeInstanceOf(Promise);61 })62 it('should call axios one time', () => {63 axios.get.mockResolvedValueOnce({data: {items: ['test', 'test2'], next: null}})64 return getFromSpotifyWithLimits('url', 'token', {params: {ids: ['setst', 'ewtewt']}})65 .then(results => {66 return expect(axios.get).toHaveBeenCalledTimes(1);67 })68 })69 it('should call axios 2 times when returned with next url', () => {70 axios.get.mockClear();71 const response1 = {data: {72 items: [],73 next: 'weirdURL'74 }}75 const response2 = {76 data: {77 items: [],78 next: null79 }80 }81 axios.get.mockResolvedValueOnce(response1);82 axios.get.mockResolvedValueOnce(response2);83 return getFromSpotifyWithLimits('url', 'token')84 .then(items => {85 return expect(axios.get).toHaveBeenCalledTimes(2);86 })87 })88 })89 describe('function getFromSpotifyByIds', () => {90 })...
index.js
Source:index.js
2const API_ENDPOINT = process.env.API_ENDPOINT;3const TILE_ENDPOINT = process.env.TILE_ENDPOINT;4const CLOUDSEARCH_ENDPOINT = process.env.CLOUDSEARCH_ENDPOINT;5export const exploracion = {6 getLayers: (locationType) => axios.get(`${API_ENDPOINT}/exploracion/layers`, {7 params: { locationType }8 }),9 getLocation: (locationType, id) => axios.get(`${API_ENDPOINT}/exploracion/location`, {10 params: { locationType, id }11 }),12 getSuggestions: str => axios.get(`${CLOUDSEARCH_ENDPOINT}`, {13 params: {14 q: `${str}*|${str}`,15 'q.parser': 'simple',16 'q.options': {17 'defaultOperator': 'and',18 'fields': ['nombre'],19 'operators': ['and', 'escape', 'fuzzy', 'near', 'not', 'or', 'phrase', 'precedence', 'prefix', 'whitespace']20 },21 return: '_all_fields,_score',22 sort: '_score desc',23 'highlight.nombre': {24 'max_phrases': 3,25 'format': 'text',26 'pre_tag': '*#*',27 'post_tag': '*%*'28 }29 }30 }),31 getVector: (field, locationType) => {32 return axios.get(`${API_ENDPOINT}/exploracion/test`, { 33 params: { locationType, field } 34 });35 }36};37export const monitoreo = {38 getVector: (caseID, index ) => axios.get(`${API_ENDPOINT}/monitor/vector`, {39 params: { caseID, index }40 }),41 getLocation: (locationType, id) => axios.get(`${API_ENDPOINT}/exploracion/location`, {42 params: { locationType, id }43 }),44};45export const ubicacion = {46 municipio: {47 getBasicInformation: id => axios.get(`${API_ENDPOINT}/municipio/${id}/general`),48 getConevalInformation: id => axios.get(`${API_ENDPOINT}/municipio/${id}/coneval`),49 getFeatures: id => axios.get(`${API_ENDPOINT}/municipio/${id}/localidades`),50 getGeoJSON: id => axios.get(`${API_ENDPOINT}/municipio/${id}/geojson`),51 getRiesgoMunicipio: id => axios.get(`${API_ENDPOINT}/municipio/${id}/riesgo`),52 getCobertura: id => axios.get(`${API_ENDPOINT}/municipio/${id}/cobertura`),53 getRecomendacion: id => axios.get(`${API_ENDPOINT}/municipio/${id}/recomendacion`),54 getCoberturaDict: id => axios.get(`${API_ENDPOINT}/informacion/cobertura`)55 },56 estado: {57 getBasicInformation: id => axios.get(`${API_ENDPOINT}/estado/${id}/general`),58 getConevalInformation: id => axios.get(`${API_ENDPOINT}/estado/${id}/coneval`),59 getFeatures: id => axios.get(`${API_ENDPOINT}/estado/${id}/municipios`),60 getGeoJSON: id => axios.get(`${API_ENDPOINT}/estado/${id}/geojson`),61 getRiesgoMunicipio: id => axios.get(`${API_ENDPOINT}/estado/${id}/riesgo`),62 getCobertura: id => axios.get(`${API_ENDPOINT}/estado/${id}/cobertura`),63 getRecomendacion: id => axios.get(`${API_ENDPOINT}/estado/${id}/recomendacion`),64 getCoberturaDict: id => axios.get(`${API_ENDPOINT}/informacion/cobertura`)65 }...
used-props.service.js
Source:used-props.service.js
1import Axios from 'axios';2const USER = 'users/';3const PROPS = 'props/';4const USED = 'used/';5const COUNT = 'count';6const props = {7 fetch(num, page, approved) {8 return Axios.get(`${PROPS}${USED}?num=${num}&page=${page}&approved=${approved}`);9 },10 fetchAll(num, page) {11 return Axios.get(`${PROPS}${USED}?num=${num}&page=${page}&all=true`);12 },13 fetchByUser(num, page, user, approved) {14 return Axios.get(`${USER}${user}/${PROPS}?num=${num}&page=${page}&approved=${approved}`);15 },16 fetchByUserAll(num, page, user) {17 return Axios.get(`${USER}${user}/${PROPS}?num=${num}&page=${page}&all=true`);18 },19 fetchByCategory(num, page, category, approved) {20 return Axios.get(`${PROPS}${USED}?num=${num}&page=${page}&category=${category}&approved=${approved}`);21 },22 fetchByCategoryAll(num, page, category) {23 return Axios.get(`${PROPS}${USED}?num=${num}&page=${page}&category=${category}&all=true`);24 },25 fetchByUserAndCategory(num, page, user, category, approved) {26 return Axios.get(`${USER}${user}/${PROPS}?num=${num}&page=${page}&category=${category}&approved=${approved}`);27 },28 fetchByUserAndCategoryAll(num, page, user, category) {29 return Axios.get(`${USER}${user}/${PROPS}?num=${num}&page=${page}&category=${category}&all=true`);30 },31 post(data) {32 return Axios.post(`${PROPS}${USED}`, data);33 },34 review(id, data) {35 return Axios.put(`${PROPS}${USED}${id}/review`, data);36 },37 delete(id) {38 return Axios.delete(`${PROPS}${USED}${id}`);39 },40 put(id, data) {41 return Axios.put(`${PROPS}${USED}${id}`, data);42 }43};44const count = {45 fetch(approved) {46 return Axios.get(`${PROPS}${USED}${COUNT}?approved=${approved}`);47 },48 fetchAll() {49 return Axios.get(`${PROPS}${USED}${COUNT}&all=true`);50 },51 fetchByUser(user, approved) {52 return Axios.get(`${USER}${user}/${PROPS}${COUNT}?approved=${approved}`);53 },54 fetchByUserAll(user) {55 return Axios.get(`${USER}${user}/${PROPS}${COUNT}?all=true`);56 },57 fetchByCategory(category, approved) {58 return Axios.get(`${PROPS}${USED}${COUNT}?category=${category}&approved=${approved}`);59 },60 fetchByCategoryAll(category) {61 return Axios.get(`${PROPS}${USED}${COUNT}?category=${category}&all=true`);62 },63 fetchByUserAndCategory(user, category, approved) {64 return Axios.get(`${USER}${user}/${PROPS}${COUNT}?category=${category}&approved=${approved}`);65 },66 fetchByUserAndCategoryAll(user, category) {67 return Axios.get(`${USER}${user}/${PROPS}${COUNT}?category=${category}&all=true`);68 }69};70export {71 props,72 count...
Using AI Code Generation
1const qawolf = require("qawolf");2const axios = require("axios");3(async () => {4 const browser = await qawolf.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.click("input[name=\"q\"]");8 await page.fill("input[name=\"q\"]", "qawolf");9 await page.press("input[name=\"q\"]", "Enter");10 await page.click("text=QA Wolf: End-to-end testing for developers");11 await page.click("text=Get started for free");12 await page.click("input[name=\"name\"]");13 await page.fill("input[name=\"name\"]", "Test");14 await page.click("input[name=\"email\"]");15 await page.fill("input[name=\"email\"]", "
Using AI Code Generation
1const axios = require("axios");2getResponse.then((response) => {3 console.log(response);4});5getResponse.catch((error) => {6 console.log(error);7});8const axios = require("axios");9});10postResponse.then((response) => {11 console.log(response);12});13postResponse.catch((error) => {14 console.log(error);15});16const axios = require("axios");17const deleteResponse = axios.delete(18);19deleteResponse.then((response) => {20 console.log(response);21});22deleteResponse.catch((error) => {23 console.log(error);24});25const axios = require("axios");26});27putResponse.then((response) => {28 console.log(response);29});30putResponse.catch((error) => {31 console.log(error);32});33const axios = require("axios");34const patchResponse = axios.patch(35 {36 }37);38patchResponse.then((response) => {39 console.log(response);40});41patchResponse.catch((error) => {42 console.log(error);43});44const axios = require("axios");
Using AI Code Generation
1const axios = require('axios');2const { URL } = require('url');3module.exports = async function get(url, params) {4 const { origin, pathname, search } = new URL(url);5 const response = await axios.get(`${origin}${pathname}`, {6 params: { ...params, __qawolf: true },7 headers: { Cookie: `__qawolf=${search}` },8 });9 return response.data;10};11const get = require('./get');12test('test', async () => {13 const { browser, page } = await qawolf.createPage();14 await page.click('button');15 await page.click('button');16 expect(text).toBe('Hello World');17 await qawolf.stopVideos();18 await browser.close();19});20const axios = require('axios');21const { URL } = require('url');22module.exports = async function get(url, params) {23 const { origin, pathname, search } = new URL(url);24 const response = await axios.get(`${origin}${pathname}`, {25 params: { ...params, __qawolf: true },26 headers: { Cookie: `__qawolf=${search}` },27 });28 return response.data;29};30const get = require('./get');31test('test', async () => {32 const { browser, page } = await qawolf.createPage();33 await page.click('button');34 await page.click('button');35 expect(text).toBe('Hello World');36 await qawolf.stopVideos();37 await browser.close();38});39const axios = require('axios');40const { URL } = require('url');41module.exports = async function get(url, params) {42 const { origin, pathname, search } = new URL(url);43 const response = await axios.get(`${origin}${pathname}`, {44 params: { ...params, __qawolf: true },45 headers: { Cookie: `__qawolf=${search}` },46 });47 return response.data;48};
Using AI Code Generation
1const axios = require('axios');2const { createBrowser } = require('qawolf');3const { URL } = require('url');4const { name } = require('./package.json');5const browser = await createBrowser();6const context = await browser.newContext();7const page = await context.newPage();8await page.click('input[title="Search"]');9await page.fill('input[title="Search"]', 'qawolf');10await page.press('input[title="Search"]', 'Enter');11await page.click('text=Q
Using AI Code Generation
1const axios = require("axios");2 .get(url)3 .then(response => console.log(response.data))4 .catch(error => console.log(error));5const axios = require("axios");6const data = {7};8 .post(url, data)9 .then(response => console.log(response.data))10 .catch(error => console.log(error));11const axios = require("axios");12const data = {13};14 .put(url, data)15 .then(response => console.log(response.data))16 .catch(error => console.log(error));17const axios = require("axios");18 .delete(url)19 .then(response => console.log(response.data))20 .catch(error => console.log(error));21const axios = require("axios");22const data = {23};24 .patch(url, data)25 .then(response => console.log(response.data))26 .catch(error => console.log(error));27const axios = require("axios");
Using AI Code Generation
1const axios = require('axios');2(async () => {3 console.log(res.data);4})();5const { launch } = require('qawolf');6const selectors = require('./selectors.json');7describe('test', () => {8 let browser;9 let page;10 beforeAll(async () => {11 browser = await launch();12 page = await browser.newPage();13 });14 afterAll(async () => {15 await browser.close();16 });17 it('test', async () => {18 await page.click(selectors['test.js']);19 const data = await res.json();20 expect(data).toEqual({21 });22 });23});
Using AI Code Generation
1const axios = require("axios");2const { createBrowser } = require("qawolf");3const { test } = require("qawolf");4const config = require("./config");5const { url } = require("./config");6const { timeout } = require("./config");7let browser;8let page;9test("test", async () => {10 try {11 browser = await createBrowser();12 page = await browser.newPage();13 await page.goto(url);14 await page.waitFor(timeout);15 const response = await axios.get(16 );17 const response2 = await axios.get(18 );19 const response3 = await axios.get(20 );21 const response4 = await axios.get(22 );23 const response5 = await axios.get(24 );25 const response6 = await axios.get(26 );27 const response7 = await axios.get(28 );29 const response8 = await axios.get(30 );31 const response9 = await axios.get(32 );33 const response10 = await axios.get(34 );
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!