weblate.js (779B)
1 import config from '../config.json'; 2 import rp from 'request-promise'; 3 4 export default class Weblate { 5 getLangs = () => { 6 const options = { 7 uri: config["weblateApiRoot"] + "languages", 8 headers: { 9 'Authorization': 'Token ' + config['weblate_token'] 10 }, 11 json: true // Automatically parses the JSON string in the response 12 }; 13 return rp(options); 14 }; 15 getProjects = () => { 16 const options = { 17 uri: config["weblateApiRoot"] + "projects", 18 headers: { 19 'Authorization': 'Token ' + config['weblate_token'] 20 }, 21 json: true // Automatically parses the JSON string in the response 22 }; 23 return rp(options); 24 } 25 }