// @flow

import qs from 'query-string'

let root: string

export function setApiRoot(url: string) {
	root = url
}

export const API = (pth: string, query: ?Object = null) => {
	if (process.env.NODE_ENV !== 'production') {
		if (!pth.startsWith('/')) {
			throw new Error('invalid path requested from the api!')
		}
	}
	let url = root + pth
	if (query) {
		url += `?${qs.stringify(query)}`
	}
	return url
}

@@ -130,16 +130,17 @@
 API = (p
+a
 th: stri
@@ -225,16 +225,17 @@
 %09%09if (!p
+a
 th.start
@@ -333,16 +333,17 @@
 root + p
+a
 th%0A%09if (

fix a typo