Every line of 'await axios get' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
12 public get(url: string, params: AxiosRequestConfig): AxiosPromise { 13 return this.http.get(url, params); 14 }
32 get(url, headers = {}, params = {}) { 33 return axios.get(this.getApiUrl(url), { 34 headers, 35 params, 36 }); 37 }
179 async __get(url) { 180 return axios.get(url, { headers: this.headers, timeout: 2000 }) 181 }
94 function asyncGet(url) { 95 return new Promise(function (resolve, reject) { 96 var xhr = new XMLHttpRequest() 97 xhr.onreadystatechange = function () { 98 if (this.readyState == 4 && this.status == 200) { 99 resolve(JSON.parse(xhr.responseText).data) 100 } else if (this.status == 401) { 101 window.location.href = LOGIN_SERVICE_URL + '/?c_url=' + window.location.href 102 } else if (this.readyState == 4 && this.status > 400) { 103 reject({ 104 status: this.status, 105 message: this.status === 503 ? '服务维护中,请稍候...' : '服务器内部异常' 106 }) 107 } 108 } 109 xhr.withCredentials = true 110 xhr.open('GET', url) 111 xhr.send() 112 }) 113 }
12 public get(url: string): Promise { 13 return new Promise((resolve, reject) => { 14 const request: Electron.ClientRequest = net.request(url); 15 16 request.on('response', (response: Electron.IncomingMessage) => { 17 if (response.statusCode !== 200) { 18 reject(new Error(`Unable to get ${url} due to ${response.statusCode} ${response.statusMessage}`)); 19 return; 20 } 21 22 let body = ''; 23 24 response.on('data', (chunk: Buffer) => { 25 body += chunk.toString(); 26 }); 27 28 response.on('end', () => { 29 resolve(body); 30 }); 31 32 response.on('error', (error: Error) => { 33 reject(error); 34 }); 35 }); 36 37 request.on('login', (authInfo: any) => { 38 reject(new Error('Proxy requiring authentication is not supported')); 39 }); 40 41 request.on('error', (error: Error) => { 42 reject(error); 43 }); 44 45 request.end(); 46 }); 47 }
37 export function get(url) { 38 return send('GET', url); 39 }
49 function get(url) { 50 return new Promise(function(resolve, reject) { 51 var req = new XMLHttpRequest(); 52 req.open('GET', url); 53 54 req.onload = function() { 55 if (req.status == 200) { 56 resolve(req.response); 57 } 58 else { 59 reject(Error("XMLHttpRequest Error: "+req.statusText)); 60 } 61 }; 62 req.onerror = function() { 63 reject(Error("Network Error")); 64 }; 65 req.send(); 66 }); 67 }
115 public get(url: string, config?: HttpClientRequestConfig): Observable> { 116 return from(axios.get(url, config)); 117 }
28 async Get(url: string, config?: AxiosRequestConfig): Promise { 29 try { 30 const result: AxiosResponse<{ errors; rows }> = await axios.get(url, config); 31 32 const data = result.data; 33 34 if (data.errors && data.errors.length > 0) { 35 const errors = []; 36 data.errors.forEach(element => { 37 errors.push(element.message); 38 }); 39 40 throw errors.toString(); 41 } 42 43 return data; 44 } catch (e) { 45 const message = (e as AxiosError).response || (e as AxiosError).message; 46 throw message; 47 } 48 }
5 function get(callback) { 6 const API = 'https://api.darksky.net/forecast'; 7 const LOCATION = `${process.env.WEATHER_LATITUDE},${process.env.WEATHER_LONGITUDE}`; 8 const QUERY = `${process.env.WEATHER_API_KEY}/${LOCATION}`; 9 const QUERYSTRING = `?units=${process.env.WEATHER_UNITS}&exclude=hourly`; 10 11 axios.get(`${API}/${QUERY}/${QUERYSTRING}`) 12 .then(function(response) { 13 let forecasts = response.data.daily.data.slice(0, 4); 14 15 forecasts = forecasts.map(function(forecast) { 16 return { 17 icon: changeCase.camel(forecast.icon), 18 time: forecast.time, 19 summary: forecast.summary, 20 humidity: Math.ceil(forecast.humidity * 100), 21 temperatureLow: Math.ceil(forecast.temperatureLow), 22 temperatureHigh: Math.ceil(forecast.temperatureHigh), 23 precipitationIntensity: Math.ceil(forecast.precipIntensity * 1000), 24 precipitationProbability: Math.ceil(forecast.precipProbability * 100) 25 }; 26 }); 27 28 callback(null, forecasts); 29 }) 30 .catch(function(err) { 31 callback(err.response.statusText, null); 32 }); 33 }