{"size": 871, "ext": "js", "max_stars_repo_path": "src/Apps/ChatBot/redux/api.ai.js", "max_stars_repo_name": "misbahkhalilaz/all_in_one_reactjs", "max_stars_repo_stars_event_min_datetime": "2020-05-11T10:35:30.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-11T10:35:30.000Z", "max_issues_repo_path": "src/redux/api.ai.js", "max_issues_repo_name": "misbahkhalilaz/react_chatbot", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/redux/api.ai.js", "max_forks_repo_name": "misbahkhalilaz/react_chatbot", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.6176470588, "max_line_length": 79, "alphanum_fraction": 0.6360505166}
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer 16d5d8e304b34c0f97ef1fee0d135b97");

export default function post(query) {
	var raw = JSON.stringify({
		//contexts: ["shop"],
		lang: "en",
		query,
		sessionId: "12345",
		timezone: "GMT+5",
	});

	var requestOptions = {
		method: "POST",
		headers: myHeaders,
		body: raw,
		redirect: "follow",
	};
	return fetch("https://api.dialogflow.com/v1/query?v=20150910", requestOptions)
		.then((res) => res.json())
		.then((res) =>
			res.status.code === 200
				? {
						query: res.result.resolvedQuery,
						resp: res.result.fulfillment.speech,
				  }
				: { query: "error", resp: res.status.code }
		);
	// .then((response) => response.text())
	// .then((result) => console.log(result))
	// .catch((error) => console.log("error", error));
}
