Skip to main content

Endpoints

With Agnost Studio, you can define your RESTful endpoints and develop your business logic using Agnost code editor.

info

The endpoint manager provides the methods to make POST, PUT, GET and DELETE requests to your app endpoints to run your serverless functions.

GET Request

You can use the get method to make a GET request to your endpoint path. Optionally, you can provide query string parameters or headers in this request.

const orderId = "620949ee991edfba3ee644e7";

// Make a GET request to /orders/{orderId} endpoint
const { data, errors } = await agnost.endpoint.get(`/orders/${orderId}`);
info
  • If errors occurred during the execution of the request then errors object is returned and the data is marked as null.
  • If no errors occured then depending on the type of the request the data object holds a single JSON object, an array of json objects, plain text, Blob or ArrayBuffer and the errors object is marked as null.
  • If the response returns no data back, then both errors and data marked as null.

Parameters

Here you can find parameters for the get method.

#

Name

Data type

Required

Description

1pathstringYesThe path of the endpoint. The endpoint path needs to start with a slash '/' character e.g., /users/profile
2queryParamsKeyValuePairNoQuery string parameters
3headersKeyValuePairNoRequest headers
4resolveTypestringNoType of data to return as a response of the request. By default response data is parsed to JSON. Possible values are "json" "text" "blob" "arraybuffer"
note

Depending on the configuration of the endpoint, an active user session might be required (e.g., user needs to be logged in) to call this method.

POST Request

You can use the post method to make a POST request to your endpoint path. Optionally, you can provide body, query string parameters or headers in this request.

const postId = "62094b43f7205e7d78082504";

// Make a POST request to /wallposts/{postId}/comments endpoint
const { data, errors } = await agnost.endpoint.post(
`/wallposts/${postId}/comments`,
{
userId: "620949ee991edfba3ee644e7",
comment:
"Awesome product. Would be better if you could add tagging people in comments.",
},
);
info
  • If errors occurred during the execution of the request then errors object is returned and the data is marked as null.
  • If no errors occured then depending on the type of the request the data object holds a single JSON object, an array of json objects, plain text, Blob or ArrayBuffer and the errors object is marked as null.
  • If the response returns no data back, then both errors and data marked as null.

Parameters

Here you can find parameters for post method.

#

Name

Data type

Required

Description

1pathstringYesThe path of the endpoint. The endpoint path needs to start with a slash '/' character e.g., /users/profile
2bodyObject or FormDataNoRequest body
3queryParamsKeyValuePairNoQuery string parameters
4headersKeyValuePairNoRequest headers
5resolveTypestringNoType of data to return as a response of the request. By default response data is parsed to JSON. Possible values are "json" "text" "blob" "arraybuffer"
note

Depending on the configuration of the endpoint, an active user session might be required (e.g., user needs to be logged in) to call this method.

PUT Request

You can use the put method to make a PUT request to your endpoint path. Optionally, you can provide body, query string parameters or headers in this request.

const userId = "62094b734848b88ff50c2ab0";

// Make a PUT request to /users/{userId}/address
const { data, errors } = await agnost.endpoint.put(`/users/${userId}/address`, {
city: "Chicago",
street: "121 W Chestnut",
zipcode: "60610",
state: "IL",
country: "US",
});
info
  • If errors occurred during the execution of the request then errors object is returned and the data is marked as null.
  • If no errors occured then depending on the type of the request the data object holds a single JSON object, an array of json objects, plain text, Blob or ArrayBuffer and the errors object is marked as null.
  • If the response returns no data back, then both errors and data marked as null.

Parameters

Here you can find parameters for the put method.

#

Name

Data type

Required

Description

1pathstringYesThe path of the endpoint. The endpoint path needs to start with a slash '/' character e.g., /users/profile
2bodyObject or FormDataNoRequest body
3queryParamsKeyValuePairNoQuery string parameters
4headersKeyValuePairNoRequest headers
5resolveTypestringNoType of data to return as a response of the request. By default response data is parsed to JSON. Possible values are "json" "text" "blob" "arraybuffer"
note

Depending on the configuration of the endpoint, an active user session might be required (e.g., user needs to be logged in) to call this method.

DELETE Request

You can use the delete method to make a DELETE request to your endpoint path. Optionally, you can provide body, query string parameters or headers in this request.

const postId = "62094b4dfcc106baba52c8ec";
const commentId = "62094b66fc475bdd5a2bfa48";

// Make a DELETE request to /wallposts/{postId}/comments/{commentId} endpoint
const { data, errors } = await agnost.endpoint.delete(
`/wallpost/${postId}/comments/${commentId}`,
);
info
  • If errors occurred during the execution of the request then errors object is returned and the data is marked as null.
  • If no errors occured then depending on the type of the request the data object holds a single JSON object, an array of json objects, plain text, Blob or ArrayBuffer and the errors object is marked as null.
  • If the response returns no data back, then both errors and data marked as null.

Parameters

Here you can find parameters for the endpoint delete method.

#

Name

Data type

Required

Description

1pathstringYesThe path of the endpoint. The endpoint path needs to start with a slash '/' character e.g., /users/profile
2bodyObject or FormDataNoRequest body
3queryParamsKeyValuePairNoQuery string parameters
4headersKeyValuePairNoRequest headers
5resolveTypestringNoType of data to return as a response of the request. By default response data is parsed to JSON. Possible values are "json" "text" "blob" "arraybuffer"
note

Depending on the configuration of the endpoint, an active user session might be required (e.g., user needs to be logged in) to call this method.