Posts

Showing posts from December 12, 2018

Fetching data from API in JavaScript

Image
up vote 3 down vote favorite I'm using Axios to fetch data from an API, and don't know if this is the best way to deal with APIs in ReactJS or not. I want to know if anyone can suggest edits or something to make the code more efficient. api.js import axios from 'axios'; export const APIendpoint = axios.create({ baseURL: 'https://1eb19101-0790-406f-90e0-ee35a2ff2d1f.mock.pstmn.io', timeout: 2000 }); matchesAction.js import {FETCH_MATCHES} from './actionTypes'; import {APIendpoint} from '../api/api'; export const fetchMatches = () => dispatch => { const matchInstance = APIendpoint.get('/matches'); matchInstance.then(response => dispatch({ type: FETCH_MATCHES, payload: response.data }) ); };

Text filtering from configuration file [duplicate]

Image
up vote 0 down vote favorite This question already has an answer here: Print lines between (and including) two patterns 2 answers We have a config file which consists of more than 24000 lines. I am stuck in one task. I need to segregate the lines starting as below (service definition of specific host in icinga2) Object Service "<host_name>"{ And ending with } Files consists multiple other entries as well I need to filter specific hosts definition alone. shell-script awk sed grep icinga2 share | improve this question edited Dec 2 at