Methods

Learn how to make HTTP requests using the `HttpService` class.


GET

HttpService.get('/posts/1')
  .then(response => console.log(response))
  .catch(error => console.error(error));

POST

const postData = {
  title: 'New Post',
  body: 'Lorem ipsum...',
  userId: 1
};

HttpService.post('/posts', postData)
  .then(response => console.log(response))
  .catch(error => console.error(error));

PUT

const updateData = {
  title: 'Updated Post',
  body: 'Updated content'
};

HttpService.put('/posts/1', updateData)
  .then(response => console.log(response))
  .catch(error => console.error(error));

DELETE

HttpService.delete('/posts/1')
  .then(response => console.log(response))
  .catch(error => console.error(error));

PATCH

const patchData = {
  body: 'Patched content'
};

HttpService.patch('/posts/1', patchData)
  .then(response => console.log(response))
  .catch(error => console.error(error));

UPLOAD

const files = [file1, file2];
const formData = {
  description: 'File description'
};

HttpService.upload('POST', '/files', files, formData)
  .then(response => console.log(response))
  .catch(error => console.error(error));