Skip to content

Latest commit

 

History

History
64 lines (45 loc) · 1.83 KB

endpoints.md

File metadata and controls

64 lines (45 loc) · 1.83 KB

Endpoints

With socket method you're able to:

  • Call other sockets via POST, GET, PATCH, PUT, DELETE methods

Import

const {socket} = new Server(ctx)

Methods

Name Description
socket Send POST request
socket.post Send POST request
socket.get Send GET request
socket.patch Send PATCH request
socket.put Send PUT request
socket.delete Send DELETE request

socket(endpoint, data?, options?)

Type Name Default Description
string endpoint null Endpoint name in format socket-name/endpoint-name
object data {} Additional data send to endpoint
object options {} Options passed to node-fetch
socket('posts/create', {title: 'Lorem ipsum'})

socket.post(endpoint, data?, options?)

socket.post('posts/create', {title: 'Lorem ipsum'})

socket.get(endpoint, data?, options?)

socket.get('posts/latest')

socket.patch(endpoint, data?, options?)

socket.patch('posts/update', {id: 10, title: 'Dolor sit amet'})

socket.put(endpoint, data?, options?)

socket.put('posts/update', {id: 23, title: 'Dolor sit amet'})

socket.delete(endpoint, data?, options?)

socket.delete('posts/delete', {id: 23})