import { API } from '../core/api' ; import { KeyValue , FileIndex } from '../models' ; import FormData from 'isomorphic-form-data' ; extends API export default class Mills extends API { param { string } name param { KeyValue } options param { any } payload param { KeyValue } headers returns async run ( name , options , payload , headers ) { let data ; if ( payload && name !== '/json' && name !== '/schema' ) { data = new FormData ( ) ; data . append ( 'file' , payload , payload . name || 'milled' ) ; } else if ( payload ) { data = JSON . stringify ( payload ) ; } const response = await this . sendPost ( `mills${ name }` , [ ] , options , data , headers , true ) ; return response . json ( ) ; } }