Change arguments to args everywhere, as arguments is a reserved word in strict
[ndcode_site.git] / js / api_call.js.min
1 Problem = class {
2   constructor(title, detail, status) {
3     this.title = title
4     this.detail = detail
5     this.status = status
6   }
7 }
8
9 api_call = async (endpoint, ...args) => {
10   let response = await fetch(
11     endpoint,
12     {method: 'POST', body: JSON.stringify(args)}
13   )
14   let result = await response.json()
15   if (!response.ok)
16     throw new Problem(result.title, result.detail, result.status)
17   return result
18 }