import config from '../config.json'

export class Api {

	fetch(method, url, param) {

		let options = {
			method : method,
			mode : 'cors',
			body : JSON.stringify(param),
			headers: {
				'Accept': 'application/json',
				'Content-Type': 'application/json'
			}

		};

		let request = new Request(config.endpoint+url, options);

		return new Promise((resolve, reject) => {
			fetch(request)
			.then(
				(response) => {
					return response.json().then((data)=>{
						resolve(data)
					});
				}
			)
		})
	}
}
