Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
class Api { constructor(apiUrl) { this.apiUrl = apiUrl; } getPurchases () { return fetch(`/purchases`, { headers: { 'Content-Type': 'application/json' } }) .then( e => { if(e.ok) { return e.json() } return Promise.reject(e.statusText) }) } addPurchases (id) { return fetch(`/purchases`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id: id }) }) .then( e => { if(e.ok) { return e.json() } return Promise.reject(e.statusText) }) } removePurchases (id){ return fetch(`/purchases/${id}`, { method: 'DELETE', headers: { 'Content-Type': 'application/json' } }) .then( e => { if(e.ok) { return e.json() } return Promise.reject(e.statusText) }) } addSubscriptions(id) { return fetch(`/subscriptions`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id: id }) }) .then( e => { if(e.ok) { return e.json() } return Promise.reject(e.statusText) }) } removeSubscriptions (id) { return fetch(`/subscriptions/${id}`, { method: 'DELETE', headers: { 'Content-Type': 'application/json' } }) .then( e => { if(e.ok) { return e.json() } return Promise.reject(e.statusText) }) } addFavorites (id) { return fetch(`/favorites`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id: id }) }) .then( e => { if(e.ok) { return e.json() } return Promise.reject(e.statusText) }) } removeFavorites (id) { return fetch(`/favorites/${id}`, { method: 'DELETE', headers: { 'Content-Type': 'application/json' } }) .then( e => { if(e.ok) { return e.json() } return Promise.reject(e.statusText) }) } getIngredients (text) { return fetch(`/ingredients?query=${text}`, { headers: { 'Content-Type': 'application/json' } }) .then( e => { if(e.ok) { return e.json() } return Promise.reject(e.statusText) }) } }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)