Best JavaScript code snippet using wpt
index.js
Source:index.js
1import service from './axios'2import qs from 'qs'3import JsEncrypt from 'jsencrypt'4//å
Œ
±key5const public_key = `-----BEGIN PUBLIC KEY-----6 MIGeMA0GCSqGSIb3DQEBAQUAA4GMADCBiAKBgGeBwE0bATN5j/AWlYAiAMRE+6FN7 JGxIXZmW2J7Qks1c+inXB4KQIuXK2a6DLfuGnxRWCTa0XJvHr6vLWvx1J8zVktOq8 1w7tA6yR5iwYfN5vS+aorsI8tcRxuNGpDtJsLS9kINGd7VH2ocmYSv8PDUKZMLqr9 i5Azz9DtRubvoQJFAgMBAAE=10 -----END PUBLIC KEY-----`11const privateKey = `12-----BEGIN RSA PRIVATE KEY-----13MIICWgIBAAKBgGeBwE0bATN5j/AWlYAiAMRE+6FNJGxIXZmW2J7Qks1c+inXB4KQ14IuXK2a6DLfuGnxRWCTa0XJvHr6vLWvx1J8zVktOq1w7tA6yR5iwYfN5vS+aorsI815tcRxuNGpDtJsLS9kINGd7VH2ocmYSv8PDUKZMLqri5Azz9DtRubvoQJFAgMBAAEC16gYAWf+fzWtlp/RTC1cXtsnaEM5KXP5OZTim6h0XTT/d5WKqwiaOCSB6t4OhsvOsz1779GItCMQlyhCXKfdKjk/A6CA6WG4DUhJywDsO9W56xp9wBBE047qukZioIHTKLbX18omsTCuIwalAKQ1uRd+9y1tf/pD/vSODBvAxOVXLvVPbJSQJBAKkm/wbz7uo9a1vV19Olu+olFHN361bygUlyA5L+pvviboXb47Bf4HemR/xENZez/rXcduCFuIkSZ+6TA320oSXVacsCQQCcpnV0C4nCP9po0GaQImJPuQz4Yacol5nODuTxS/GjRl/BVWbEp/qo21tMjalmSuDXiiwjzYp43c3kk2Qx6v/QIvAkBAsCghmZIJxJlVElNyGJJssOaZL3um22AVHWQeiAKGG48W5APMRK5MM6wd3lv8expypDBWJu1uhjp284QF4BYP9HAkA+3R4t23X6P87Br+DQPbu7CwRZbK5oVqaMw0QQ3nN47U8xziPR9ss+yHX2VrMwdcQdOznTdF24ypfHlvzSZcUe4u3JAkBIGDs4HLojgf05f/c17zN/Zav+D7aMHAYr2ZM5PGmIv4MJ25rlPH5K63Mupv/Lb+2rVVI0os6nEeLo5v7sWQjoNG26-----END RSA PRIVATE KEY-----`27export const RSAencrypt = str => {28 let BLOCK_SIZE = 100,29 jse = new JSEncrypt(),30 ret = '',31 str_1 = ''32 jse.setPublicKey(public_key)33 while (str.length > 0) {34 var i = BLOCK_SIZE35 if (str.length < i) {36 i = str.length37 }38 str_1 = str.substr(0, i)39 str = str.substr(i, str.length - i)40 ret += jse.encrypt(str_1) + ' '41 }42 return ret43}44export const decryptData = data => {45 let decrypt = new JSEncrypt()46 // 设置ç§é¥47 decrypt.setPrivateKey(privateKey)48 // 解å¯æ°æ®49 return decrypt.decrypt(data)50}51//ç»å½52export const login = formData =>53 service.request({54 method: 'post',55 url: 'default/userlogin',56 data: qs.stringify(formData)57 })58//ç»åº59export const loginOut = formData =>60 service.request({61 method: 'post',62 url: 'default/logout'63 })64//ä¿®æ¹ç»å½å¯ç 65export const changeuserloginpass = formData =>66 service.request({67 method: 'post',68 url: 'user/changeuserloginpass',69 data: qs.stringify(formData)70 })71//è·åéé¢72export const getbalance = formData =>73 service.request({74 method: 'post',75 url: 'user/getbalance'76 })77//æ¥è¯¢èµéå¯ç 78export const getsecpass = formData =>79 service.request({80 method: 'post',81 url: 'security/checksecpassexist'82 })83//éªè¯èµéå¯ç 84export const checksecpass = formData =>85 service.request({86 method: 'post',87 url: 'security/checksecpass',88 data: qs.stringify(formData)89 })90//使ç¨å¯ä¿æ¾åèµéå¯ç 91export const changeusersecpass = formData =>92 service.request({93 method: 'post',94 url: 'user/changeusersecpass',95 data: qs.stringify(formData)96 })97//设置å¯ä¿é®é¢98export const setsequestion = formData =>99 service.request({100 method: 'post',101 url: 'user/setsequestion',102 data: qs.stringify(formData)103 })104//åå¾å
å设置çå¯ä¿é®é¢105export const checksequestion = formData =>106 service.request({107 method: 'post',108 url: 'security/checksequestion',109 data: qs.stringify(formData)110 })111//ä¿®æ¹æµç§°112export const updatenickname = formData =>113 service.request({114 method: 'post',115 url: 'user/adduserbank',116 data: qs.stringify({ nickname: 'test001' })117 })118//æ¥è¯¢é¶è¡å¡119export const getbankinfo = formData =>120 service.request({121 method: 'post',122 url: 'user/getuserbankinfo',123 data: qs.stringify(formData)124 })125//æ·»å é¶è¡å¡126export const adduserbank = formData =>127 service.request({128 method: 'post',129 url: 'user/adduserbank',130 data: qs.stringify(formData)131 })132//è·åç³»ç»éç¥133export const getnotice = formData =>134 service.request({135 method: 'post',136 url: `getnotice`137 })138//è·åè¡æ¿åºå表139export const getprovincelist = formData =>140 service.request({141 method: 'post',142 url: 'area/getprovincelist',143 data: qs.stringify(formData)144 })145//è·ååå¸å表146export const getcitylist = formData =>147 service.request({148 method: 'post',149 url: 'area/getcitylist',150 data: qs.stringify(formData)151 })152//è·åé¶è¡å表153export const getbanklist = formData =>154 service.request({155 method: 'post',156 url: 'bankmanage/getbanklist',157 data: qs.stringify(formData)158 })159//è·åä¸çº§èµè®¯160export const getchildlist = formData =>161 service.request({162 method: 'post',163 url: 'user/getchildlist'164 })165//è·å使ç¨è
彩ç§166export const getuserlottery = formData =>167 service.request({168 method: 'post',169 url: 'user/getuserlottery'170 })171//è·åç¨æ·å½©ç§ç©æ³172export const getuserlotterymethod = formData =>173 service.request({174 method: 'post',175 url: 'user/getuserlotterymethod',176 data: qs.stringify(formData)177 })178//æ¥è©¢æ注è¨é179export const getbethistory = formData =>180 service.request({181 method: 'post',182 url: 'gameinfo/getbethistory',183 data: qs.stringify(formData)184 })185//è·åææ游æå¸åç±»å186export const getallordertype = formData =>187 service.request({188 method: 'post',189 url: 'report/getallordertype'190 })191//游æå¸åè®°å½192export const getorderhistory = formData =>193 service.request({194 method: 'post',195 url: 'report/getorderhistory',196 data: qs.stringify(formData)197 })198//æ¥è©¢æå®æé段å
§ç追èæ注è¨é199export const gettaskhistory = formData =>200 service.request({201 method: 'post',202 url: 'gameinfo/gettaskhistory',203 data: qs.stringify(formData)204 })205//æ¥è¯¢è¿½å·è®°å½è¯¦æ
206export const gettaskhistorydetail = formData =>207 service.request({208 method: 'post',209 url: 'gameinfo/gettaskhistorydetail',210 data: qs.stringify(formData)211 })212//追èæ¤å®æ¥å£213export const traceordercancel = formData =>214 service.request({215 method: 'post',216 url: 'traceordercancel',217 data: qs.stringify(formData)218 })219//ééæ²å¸³è®è¨é220export const getbankreporthistory = formData =>221 service.request({222 method: 'post',223 url: 'report/getbankreporthistory',224 data: qs.stringify(formData)225 })226//è·åææé游æå¸åç±»å227export const getallbankreporttype = formData =>228 service.request({229 method: 'post',230 url: 'report/getallbankreporttype',231 data: qs.stringify(formData)232 })233//è·å彩票èå234export const getMenu = formData =>235 service.request({236 method: 'post',237 url: 'lottery/getmenu'238 })239//ç²å彩票信æ¯çéçµåç©æ³ç240export const getLotteryInfo = formData =>241 service.request({242 method: 'post',243 url: 'lottery/getinfo',244 data: qs.stringify(formData)245 })246//ç²åå½å彩ç§å¥æ247export const getissue = formData =>248 service.request({249 method: 'post',250 url: `getissue`,251 data: qs.stringify(formData)252 })253//ç²åä¸çè碼æ¥å£254export const getprize = formData =>255 service.request({256 method: 'post',257 url: `getprize`,258 data: qs.stringify(formData)259 })260//æ注æ¥å£261export const betting = formData =>262 service.request({263 method: 'post',264 url: `lottery/betting`,265 data: qs.stringify(formData)266 })267//æ¤åæ¥å£268export const ordercancel = formData =>269 service.request({270 method: 'post',271 url: `ordercancel`,272 data: qs.stringify(formData)273 })274//ç²åæè¿50æ¢çæä¿¡æ¯275export const getcreateissues = formData =>276 service.request({277 method: 'post',278 url: `getcreateissues`,279 data: qs.stringify(formData)280 })281//è·åæ¶å°çæ¶æ¯282export const getmessage = formData =>283 service.request({284 method: 'post',285 url: 'user/getmessage',286 data: qs.stringify(formData)287 })288//è·åæ¶æ¯å
容289export const getmessagecontent = formData =>290 service.request({291 method: 'post',292 url: 'user/getmessagecontent',293 data: qs.stringify(formData)294 })295//å é¤åéçæ¶æ¯296export const deletemessage = formData =>297 service.request({298 method: 'post',299 url: 'user/deletemessage',300 data: qs.stringify(formData)301 })302//è·åå·²åéçæ¶æ¯303export const getSendMessage = formData =>304 service.request({305 method: 'post',306 url: 'user/getmessage',307 data: qs.stringify(formData)308 })309//åæ¶æ¯ç»ä¸çº§310export const sendmessagetochild = formData =>311 service.request({312 method: 'post',313 url: 'user/sendmessagetochild',314 data: qs.stringify(formData)315 })316//åæ¶æ¯ç»ä¸çº§317export const sendmessagetoparent = formData =>318 service.request({319 method: 'post',320 url: 'user/sendmessagetoparent',321 data: qs.stringify(formData)322 })323//åå¤ä¿¡æ¯324export const messagereply = formData =>325 service.request({326 method: 'post',327 url: 'user/messagereply',328 data: qs.stringify(formData)329 })330//è·åæªè¯»æ¶æ¯æ°é331export const getunreadmessageamount = formData =>332 service.request({333 method: 'post',334 url: 'user/getunreadmessageamount',335 data: qs.stringify(formData)336 })337//è·åæ¨å¹¿é¾æ¥å¥éç»å¯éèå´338export const getreglink = formData =>339 service.request({340 method: 'post',341 url: 'user/getreglink'342 })343//è·åæ¨å¹¿é¾æ¥å¥éç»å¯éèå´344export const addnewuser = formData =>345 service.request({346 method: 'post',347 url: 'user/addnewuser',348 data: qs.stringify(formData)349 })350//å é¤æ¨å¹¿é¾æ¥351export const delreglink = formData =>352 service.request({353 method: 'post',354 url: 'user/delreglink',355 data: qs.stringify(formData)356 })357//代ç设置æ¨å¹¿é¾ç»358export const setreglink = formData =>359 service.request({360 method: 'post',361 url: 'user/setreglink',362 data: qs.stringify(formData)363 })364//è·åå¢é管çæ¸
å365export const getgrouplist = formData =>366 service.request({367 method: 'post',368 url: 'user/getgrouplist',369 data: qs.stringify(formData)370 })371//è·åè¿ç¹è®¾ç½®æ¡ä»¶-è¿ç¹è®¾ç½®372export const setpoints = formData =>373 service.request({374 method: 'post',375 url: 'user/setpoints',376 data: qs.stringify(formData)377 })378//è·åå¢éä½é¢379export const getgroupbalance = formData =>380 service.request({381 method: 'post',382 url: 'user/getgroupbalance',383 data: qs.stringify(formData)384 })385//è·åä¿¡ç¨è®¾ç½®æ¡ä»¶386export const setcredit = formData =>387 service.request({388 method: 'post',389 url: 'credit/setcredit',390 data: qs.stringify(formData)391 })392//åå¾å
å¼æ¡ä»¶393export const topup = formData =>394 service.request({395 method: 'post',396 url: 'user/topup',397 data: qs.stringify(formData)398 })399//è·åè系信æ¯ç®¡çæ¸
å400export const getemailbindlist = formData =>401 service.request({402 method: 'post',403 url: 'user/getemailbindlist'404 })405//è¨ç½®è系信æ¯406export const setemailbind = formData =>407 service.request({408 method: 'post',409 url: 'user/setemailbind',410 data: qs.stringify(formData)411 })412//è·åæ´»å¨å表413export const getactivitylist = formData =>414 service.request({415 method: 'post',416 url: 'activity/getactivitylist'417 })418//è·åæ´»å¨å表419export const getactivityinfo = formData =>420 service.request({421 method: 'post',422 url: 'activity/getactivityinfo',423 data: qs.stringify(formData)424 })425//注å-è·å注åéªè¯ç 426export const popularizereg = formData =>427 service.request({428 method: 'post',429 url: 'user/popularizereg',430 data: qs.stringify(formData)431 })432//å¢éçäºæ¥è¡¨433export const reallist = formData =>434 service.request({435 method: 'post',436 url: 'report/reallist',437 data: qs.stringify(formData)438 })439//ä¿®æ¹é¶è¡å¡440export const updateuserbankcard = formData =>441 service.request({442 method: 'post',443 url: 'user/updateuserbankcard',444 data: qs.stringify(formData)...
admin.service.ts
Source:admin.service.ts
1import { Injectable } from '@angular/core';2import { HttpClient } from '@angular/common/http';3import { Observable } from 'rxjs';4import { VendorDetails } from '../component/vendoraccount/vendoraccount.component';5import { GstDetails } from './gst/gst.component';6@Injectable({7 providedIn: 'root'8})9export class AdminService {10 11 hitsReceivedFun() {12 return this.http.get('https://takeoff-pavan.herokuapp.com/hitsReceived');13 }14 getContacts() {15 return this.http.get('https://takeoff-pavan.herokuapp.com/getContacts');16 }17 getScanCodes() {18 return this.http.get('https://takeoff-pavan.herokuapp.com/getScanCodes');19 }20 tdsDetails(formData: FormData) {21 return this.http.post('https://takeoff-pavan.herokuapp.com/getTDS',formData);22 }23 getWalletBalance() {24 return this.http.get('https://takeoff-pavan.herokuapp.com/getWalletBalance');25 }26 getUserStats() {27 return this.http.get('https://takeoff-pavan.herokuapp.com/getUserStats');28 }29 getAllCustomerAccountDetails() {30 return this.http.get('https://takeoff-pavan.herokuapp.com/getAllCustomerAccountDetails');31 }32 downloadGST(gstDetailsList: GstDetails[]) {33 return this.http.post('https://takeoff-pavan.herokuapp.com/downloadGST',gstDetailsList,{responseType: 'blob'});34 }35 gstDetails() {36 return this.http.get('https://takeoff-pavan.herokuapp.com/gstDetails');37 }38 takeOffStatement(formData: FormData) {39 return this.http.post('https://takeoff-pavan.herokuapp.com/takeOffStatement',formData);40 }41 creditAmount(formData: FormData) {42 return this.http.post('https://takeoff-pavan.herokuapp.com/creditAmount',formData);43 }44 verifyPanStatus(formData: FormData) {45 return this.http.post('https://takeoff-pavan.herokuapp.com/verifyPanStatus',formData);46 }47 verifyKycStatus(formData: FormData) {48 return this.http.post('https://takeoff-pavan.herokuapp.com/verifyKycStatus',formData);49 }50 editDesigner(designer: VendorDetails) {51 return this.http.post('https://takeoff-pavan.herokuapp.com/editDesigner',designer);52 }53 editVendor(vendor: VendorDetails) {54 return this.http.post('https://takeoff-pavan.herokuapp.com/editVendor',vendor);55 }56 addDesigner(designer: VendorDetails) {57 return this.http.post('https://takeoff-pavan.herokuapp.com/addDesigner',designer);58 }59 addInvestor(designer: VendorDetails) {60 return this.http.post('https://takeoff-pavan.herokuapp.com/addInvestor',designer);61 }62 63 addExecutive(designer: VendorDetails) {64 return this.http.post('https://takeoff-pavan.herokuapp.com/addExecutive',designer);65 }66 getExecutives() {67 return this.http.get('https://takeoff-pavan.herokuapp.com/getExecutives');68 }69 70 addVendor(designer: VendorDetails) {71 return this.http.post('https://takeoff-pavan.herokuapp.com/addVendor',designer);72 }73 disableDesigner(formData: FormData) {74 return this.http.post('https://takeoff-pavan.herokuapp.com/disableDesigner',formData);75 }76 deleteDesigner(formData: FormData) {77 return this.http.post('https://takeoff-pavan.herokuapp.com/deleteDesigner',formData);78 }79 disableVendor(formData: FormData) {80 return this.http.post('https://takeoff-pavan.herokuapp.com/disableVendor',formData);81 }82 deleteVendor(formData: FormData) {83 return this.http.post('https://takeoff-pavan.herokuapp.com/deleteVendor',formData);84 }85 getVendors() {86 return this.http.get('https://takeoff-pavan.herokuapp.com/getVendors');87 }88 getDesigners() {89 return this.http.get('https://takeoff-pavan.herokuapp.com/getDesigners');90 }91 getInvestors() {92 return this.http.get('https://takeoff-pavan.herokuapp.com/getInvestors');93 }94 mandatoryComplimentaryChange(formData: FormData) {95 return this.http.post('https://takeoff-pavan.herokuapp.com/mandatoryComplimentaryChange',formData);96 }97 deleteSubCategory(formData: FormData) {98 return this.http.post('https://takeoff-pavan.herokuapp.com/deleteSubCategory',formData);99 }100 deleteCategory(formData: FormData) {101 return this.http.post('https://takeoff-pavan.herokuapp.com/deleteCategory',formData);102 }103 deleteCouponType(formData: FormData) {104 return this.http.post('https://takeoff-pavan.herokuapp.com/deleteCouponType',formData);105 }106 107 visibleCouponType(formData: FormData) {108 return this.http.post('https://takeoff-pavan.herokuapp.com/visibleCouponType',formData);109 }110 visibleSubCategory(formData: FormData) {111 return this.http.post('https://takeoff-pavan.herokuapp.com/visibleSubCategory',formData);112 }113 visibleCategory(formData: FormData) {114 return this.http.post('https://takeoff-pavan.herokuapp.com/visibleCategory',formData);115 }116 editSubCategory(formData: FormData) {117 return this.http.post('https://takeoff-pavan.herokuapp.com/editSubCategory',formData);118 }119 editCategory(formData: FormData) {120 return this.http.post('https://takeoff-pavan.herokuapp.com/editCategory',formData);121 }122 editCouponType(formData: FormData) {123 return this.http.post('https://takeoff-pavan.herokuapp.com/editCouponType',formData);124 }125 constructor(private http: HttpClient) { }126 isContactNumber(value: string): Boolean127{128 129 return ((value != null) &&130 (value !== '') &&131 !isNaN(Number(value.toString())) && (value.trim().length == 10));132}133 134 getAllSubCategories(): Observable<any>135 {136 return this.http.get('https://takeoff-pavan.herokuapp.com/getAllSubCategories');137 }138 addCategory(formData: FormData): Observable<any>139 {140 return this.http.post('https://takeoff-pavan.herokuapp.com/addCategory',formData);141 }142 addCouponType(formData: FormData): Observable<any>143 {144 return this.http.post('https://takeoff-pavan.herokuapp.com/addCouponType',formData);145 }146 addSubCategory(formData: FormData): Observable<any>147 {148 return this.http.post('https://takeoff-pavan.herokuapp.com/addSubCategory',formData);149 }...
universityApiCall.js
Source:universityApiCall.js
1import { API } from "../../backend";2// create a university3export const createUniversity = (userId, token, university, countryId) => {4 const formData = new FormData();5 formData.append("picture", university.picture);6 formData.append("name", university.name);7 formData.append("facts", university.facts);8 formData.append("description", university.description);9 formData.append("awards", university.awards);10 formData.append("achievements", university.achievements);11 formData.append("affiliatedBy", university.affiliatedBy);12 formData.append("recent", university.recent);13 formData.append("climate", university.climate);14 formData.append("why", university.why);15 formData.append("nowDays", university.nowDays);16 formData.append("figures", university.figures);17 formData.append("faculties", university.faculties);18 formData.append("trainingFields", university.trainingFields);19 formData.append("general", university.general);20 formData.append("duration", university.duration);21 console.log(formData);22 return fetch(`${API}university/create/${countryId}/${userId}`, {23 method: "POST",24 headers: {25 Accept: "mulitpart/form-data",26 Authorization: `Bearer ${token}`,27 },28 body: formData,29 })30 .then((response) => {31 return response.json();32 })33 .catch((err) => console.log(err));34};35// get All universities36export const getUniversities = (userId, token) => {37 return fetch(`${API}universities/${userId}`, {38 method: "GET",39 headers: {40 Authorization: `Bearer ${token}`,41 "Content-type": "application/json",42 },43 })44 .then((response) => {45 return response.json();46 })47 .catch((err) => console.log(err));48};49// get a University50export const getUniversity = (universityId, token) => {51 return fetch(`$(API)university/${universityId}`, {52 method: "GET",53 headers: {54 "Content-type": "application/json",55 Authorization: `Bearer ${token}`,56 },57 })58 .then((response) => {59 return response.json();60 })61 .catch((err) => console.log(err));62};63// update a University64export const updateUniversity = (universityId, userId, token, university) => {65 const formData = new FormData();66 formData.append("picture", university.picture);67 formData.append("name", university.name);68 formData.append("facts", university.facts);69 formData.append("description", university.description);70 formData.append("awards", university.awards);71 formData.append("achievements", university.achievements);72 formData.append("affiliatedBy", university.affiliatedBy);73 formData.append("recent", university.recent);74 formData.append("climate", university.climate);75 formData.append("why", university.why);76 formData.append("nowDays", university.nowDays);77 formData.append("figures", university.figures);78 formData.append("faculties", university.faculties);79 formData.append("trainingFields", university.trainingFields);80 formData.append("general", university.general);81 formData.append("duration", university.duration);82 // console.log(formData);83 return fetch(`${API}university/${universityId}/${userId}`, {84 method: "PUT",85 headers: {86 Accept: "mulitpart/form-data",87 Authorization: `Bearer ${token}`,88 },89 body: formData,90 })91 .then((response) => {92 return response.json();93 })94 .catch((err) => console.log(err));95};96// delete a country97export const deleteUniversity = (universityId, userId, token) => {98 return fetch(`${API}university/${universityId}/${userId}`, {99 method: "DELETE",100 headers: {101 "Content-type": "application/json",102 Authorization: `Bearer ${token}`,103 },104 })105 .then((response) => {106 return response.json();107 })108 .catch((err) => console.log(err));...
countryApiCall.js
Source:countryApiCall.js
1import { API } from "../../backend";2// create a country3export const createCountry = (userId, token, country) => {4 const formData = new FormData();5 formData.append("picture", country.picture);6 formData.append("name", country.name);7 formData.append("description", country.description);8 formData.append("capital", country.capital);9 formData.append("currency", country.currency);10 formData.append("countryCode", country.countryCode);11 formData.append("timeZone", country.timeZone);12 formData.append("religion", country.religion);13 formData.append("language", country.language);14 formData.append("living", country.living);15 formData.append("firstYearPackage", country.firstYearPackage);16 formData.append("documents", country.documents);17 formData.append("eligibility", country.eligibility);18 formData.append("duration", country.duration);19 formData.append("intake", country.intake);20 formData.append("holydays", country.holydays);21 formData.append("ourServices", country.ourServices);22 formData.append("memberOf", country.memberOf);23 formData.append("whyStudy", country.whyStudy);24 return fetch(`${API}country/create/${userId}`, {25 method: "POST",26 headers: {27 Accept: "mulitpart/form-data",28 Authorization: `Bearer ${token}`,29 },30 body: formData,31 })32 .then((response) => {33 return response.json();34 })35 .then((err) => console.log(err));36};37// get All countries38export const getCountrys = () => {39 return fetch(`${API}countries`, {40 method: "GET",41 })42 .then((response) => {43 return response.json();44 })45 .catch((err) => console.log(err));46};47// get a Country48export const getCountry = (countryId) => {49 return fetch(`$(API)country/${countryId}`, {50 method: "GET",51 })52 .then((response) => {53 return response.json();54 })55 .catch((err) => console.log(err));56};57// update a country58export const updateCountry = (countryId, userId, token, country) => {59 const formData = new FormData();60 formData.append("picture", country.picture);61 formData.append("name", country.name);62 formData.append("description", country.description);63 formData.append("capital", country.capital);64 formData.append("currency", country.currency);65 formData.append("countryCode", country.countryCode);66 formData.append("timeZone", country.timeZone);67 formData.append("religion", country.religion);68 formData.append("language", country.language);69 formData.append("living", country.living);70 formData.append("firstYearPackage", country.firstYearPackage);71 formData.append("documents", country.documents);72 formData.append("eligibility", country.eligibility);73 formData.append("duration", country.duration);74 formData.append("intake", country.intake);75 formData.append("holydays", country.holydays);76 formData.append("ourServices", country.ourServices);77 formData.append("memberOf", country.memberOf);78 formData.append("whyStudy", country.whyStudy);79 return fetch(`${API}country/${countryId}/${userId}`, {80 method: "PUT",81 headers: {82 Accept: "multipart/form-data",83 Authorization: `Bearer ${token}`,84 },85 body: formData,86 })87 .then((response) => {88 return response.json();89 })90 .catch((err) => console.log(err));91};92// delete a country93export const deleteCountry = (countryId, userId, token) => {94 return fetch(`${API}country/${countryId}/${userId}`, {95 method: "DELETE",96 headers: {97 Accept: "multipart/form-data",98 Authorization: `Bearer ${token}`,99 },100 })101 .then((response) => {102 return response.json();103 })104 .catch((err) => console.log(err));...
Using AI Code Generation
1var wpt = require('webpagetest');2var test = new wpt('www.webpagetest.org');3 if (err) return console.error(err);4 console.log('Test status:', data.statusText);5 console.log('Test ID:', data.data.testId);6 console.log('Test URL:', data.data.userUrl);7 console.log('Test results:', data.data.summary);8});9var wpt = require('webpagetest');10var test = new wpt('www.webpagetest.org');11 .then(function(data) {12 console.log('Test status:', data.statusText);13 console.log('Test ID:', data.data.testId);14 console.log('Test URL:', data.data.userUrl);15 console.log('Test results:', data.data.summary);16 })17 .catch(function(err) {18 console.error('Error:', err);19 });20var wpt = require('webpagetest');21var test = new wpt('www.webpagetest.org');22 .then(function(data) {23 console.log('Test status:', data.statusText);24 console.log('Test ID:', data.data.testId);25 console.log('Test URL:', data.data.userUrl);26 console.log('Test results:', data.data.summary);27 })28 .catch(function(err) {29 console.error('Error:', err);30 });31var wpt = require('webpagetest');32var test = new wpt('www.webpagetest.org');33 .then(function(data) {34 console.log('Test status:', data.statusText);35 console.log('Test ID:', data.data.testId);36 console.log('Test URL:', data.data.userUrl);37 console.log('Test results:', data.data.summary);38 })39 .catch(function(err) {40 console.error('Error:', err);41 });
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4 videoParams: {5 }6};7 if (err) return console.error(err);8 console.log('Test submitted to WebPagetest for %s\n', data.data.testUrl);9 console.log('View your test at: %s\n', data.data.userUrl);10});11var wpt = require('webpagetest');12var wpt = new WebPageTest('www.webpagetest.org');13var options = {14 videoParams: {15 }16};17 if (err) return console.error(err);18 console.log('Test submitted to WebPagetest for %s\n', data.data.testUrl);19 console.log('View your test at: %s\n', data.data.userUrl);20});21var wpt = require('webpagetest');22var wpt = new WebPageTest('www.webpagetest.org');23var options = {24 videoParams: {25 }26};27 if (err) return console.error(err);28 console.log('Test submitted to WebPagetest for %
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3var formData = {4};5wpt.runTest(formData, function(err, data) {6 if (err) console.log(err);7 else console.log(data);8});9var wpt = require('wpt');10var wpt = new WebPageTest('www.webpagetest.org');11var formData = {12};13wpt.runTest(formData, function(err, data) {14 if (err) console.log(err);15 else console.log(data);16});17var wpt = require('wpt');18var wpt = new WebPageTest('www.webpagetest.org');19var formData = {20};21wpt.runTest(formData, function(err, data) {22 if (err) console.log(err);23 else console.log(data);24});25var wpt = require('wpt');26var wpt = new WebPageTest('www.webpagetest.org');27var formData = {28};29wpt.runTest(formData, function(err, data) {30 if (err) console.log(err);31 else console.log(data);32});33var wpt = require('wpt');34var wpt = new WebPageTest('www.webpagetest.org');35var formData = {
Using AI Code Generation
1var page = require('webpage').create();2var system = require('system');3var fs = require('fs');4var url = system.args[1];5var data = system.args[2];6var data = JSON.parse(data);7var method = system.args[3];8var headers = system.args[4];9var headers = JSON.parse(headers);10page.onConsoleMessage = function(msg) {11 console.log(msg);12};13page.open(url, method, data, headers, function(status) {14 if (status === 'success') {15 console.log(page.content);16 } else {17 console.log('FAIL to load the address');18 }19 phantom.exit();20});21var page = require('webpage').create();22var system = require('system');23var fs = require('fs');24var url = system.args[1];25var data = system.args[2];26var data = JSON.parse(data);27var method = system.args[3];28var headers = system.args[4];29var headers = JSON.parse(headers);30page.onConsoleMessage = function(msg) {31 console.log(msg);32};33page.open(url, method, data, headers, function(status) {34 if (status === 'success') {35 console.log(page.content);36 } else {37 console.log('FAIL to load the address');38 }39 phantom.exit();40});41var page = require('webpage').create();42var system = require('system');43var fs = require('fs');44var url = system.args[1];45var data = system.args[2];46var data = JSON.parse(data);47var method = system.args[3];48var headers = system.args[4];49var headers = JSON.parse(headers);50page.onConsoleMessage = function(msg) {51 console.log(msg);52};53page.open(url
Using AI Code Generation
1var wpt = require('wpt');2 if (err) return console.log(err);3 console.log('Test status: ' + data.statusCode);4 console.log('Test ID: ' + data.data.testId);5});6var wpt = require('wpt');7 if (err) return console.log(err);8 console.log('Test status: ' + data.statusCode);9 console.log('Test ID: ' + data.data.testId);10});11var wpt = require('wpt');12 if (err) return console.log(err);13 console.log('Test status: ' + data.statusCode);14 console.log('Test ID: ' + data.data.testId);15});16var wpt = require('wpt');17 if (err) return console.log(err);18 console.log('Test status: ' + data.statusCode);19 console.log('Test ID: ' + data.data.testId);20});21var wpt = require('wpt');22 if (err) return console.log(err);23 console.log('Test status: ' + data.statusCode);24 console.log('Test ID: ' + data.data.testId);25});26var wpt = require('wpt');27 if (err) return console.log(err);28 console.log('Test status:
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!!