Creating class and importing
const request = require('superagent')
var stationState =
{
url: 'http://localhost:9011/api',
stationID: "xxxxx",
async: false
}
export class WMSService {
sendDirectionToLaser(laserIP, offset) {
return request.post(`${stationState.url}/laserDirection`)
.set('Content-Type', 'application/json')
.send({"laserIP": laserIP ,"offset": offset})
.end(function (response) {
console.log(response)
})
}
postResults (location, coords, gate, stationName) {
// console.log('location b:'+location,'cords b:'+ coords)
return request.post(`${stationState.url}/laserSettings`)
.set('Content-Type', 'application/json')
.send({"location": location, "coords": coords, "gate": gate, "stationName": stationName })
.end(function (response) {
console.log('response statusCode', response);
})
}
}
export default WMSService
// import and declare
import WMSService from '@/utils/WMSService'
const wmsService = new WMSService()
// then use as normal
wmsService.function