Easy way to call Syncano Sockets.
Name | Description |
---|---|
Syncano | Create Syncano connection |
s | Send POST request |
s.get | Send GET request |
s.post | Send POST request |
s.patch | Send PATCH request |
s.put | Send PUT request |
s.delete | Send DELETE request |
Type | Name | Default | Description |
---|---|---|---|
string | instanceName |
undefined | Syncano Instance name. You can create one using Syncano CLI |
object | options |
{} | Additional connection options |
string | options.host |
syncano.space | Syncano host name. |
string | options.token |
undefined | Allows you to initialize authorized connection. |
string | options.transformResponse |
undefined | Define custom response format. (EXPERIMENTAL) |
Create connection
const s = new Syncano('INSTANCE_NAME')
Type | Name | Default | Description |
---|---|---|---|
string | endpoint |
undefined | Name of socket and endpoint joined with '/' |
object/FormData | data |
{} | Optional object send with request |
object | options |
{} | Optional request configuration, see axios options |
string | options.headers |
{} | Request headers |
Send GET
request to Syncano Socket.
Simple Request
// countries - socket name
// list - endpoint name
s.get('countries/list')
.then(res => {
// Handle response
})
.catch(err => {
// Handle error
})
Pass additional data to request
s.get('countries/list', { order_by: 'name' })
Send request with headers
s.get('countries/list', {}, {
headers: {
'Content-Type': 'application/json'
}
})
For more options, view axios documentation
Send POST
request to Syncano Socket. View s.get
method for more info.
Send DELETE
request to Syncano Socket. View s.get
method for more info.
Send PUT
request to Syncano Socket. View s.get
method for more info.
Send PATCH
request to Syncano Socket. View s.get
method for more info.