Expanding functionality: Steps to integrating a new endpoint into your AWS Amplify Express Server

I have created a REST express server using Amplify.

Attempted to include two additional endpoints:

// incorporating serverless express
app.post('/myendpoint', function(req, res) {
  console.log('body: ', req.body)
  res.json(req.body)
});

// utilizing serverless express
app.get('/myendpoint', function(req, res) {
  res.json({success: 'get call to my endpoint succeed!', url: req.url});
});

Despite running amplify push, these new endpoints are not visible in the console and requests cannot be made to them via amplify.

The original configuration endpoints are functional. What is the correct procedure for adding more REST endpoints? It seems like I may have missed an additional configuration step.

Answer №1

Once the API and function have been deployed, to incorporate an extra path it is recommended to utilize the "amplify update api" command.

Answer №2

When using the "amplify update api" command, Kevin Le mentioned that you can easily add new root paths like "/items" or "/customers". However, I have encountered difficulties when trying to add nested paths such as "/customer/addAddress" after creating the initial API.

Here are some things I have attempted:

  1. I can include nested paths during the initial API setup, but not when updating it later on
  2. I tried modifying the cloud formation template to incorporate the nested paths in the API gateway, but any requests to these paths were intercepted by the root path's proxy
  3. Adding the nested paths directly in the express lambda function seemed like a workaround, but it goes against the purpose of utilizing API Gateway

In order to truly leverage the power of API Gateway and make the most out of Amplify's REST API capabilities, there is a need for enhancements. It would be beneficial to have the ability to separate functions for different HTTP methods like GET, POST, PUT, etc.

UPDATE: After further investigation, I discovered a solution to this issue. By removing the {proxy} endpoint associated with the "root" path in the cloud formation file for the API gateway, located at: "project root"/amplify/backend/api/"api name"/"api name"-cloudformation-template.json, the issue was resolved. Simply delete the path found under Resources->"api name"->Properties->Body->paths->"api name"/{proxy+}.

FURTHER INVESTIGATION: Although I have yet to test this, it is possible that the order of paths listed in the cloud formation file could impact how requests are processed. By reorganizing the paths so that the "root" proxy is placed last, it may eliminate the need to remove it altogether. Special thanks to Piotr for helping me correct my grammar!

Answer №3

To update your API in Amplify, simply run the command "amplify update api". From there, you can add a new endpoint and select a new or existing Lambda function to assign to that endpoint.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Managing multiple client requests at the same time with Node and Express

I am faced with the challenge of handling multiple user requests simultaneously in my express server and storing their data in a MongoDB. While I have all the necessary code prepared, I am struggling to devise a method for assigning a unique identifier to ...

Enhance your AngularJS skills by incorporating multiple conditions into the ternary operations of ng-class

I am struggling to apply multiple classes when the condition in the ng-class attribute evaluates to true. Here is the code I have attempted so far, but it doesn't seem to be working: <div class="col-md-4" ng-mouseover="hoverButton=true" id="plai ...

Information displays instantly in the initial milliseconds

When developing dynamic web pages with Nuxt, I encountered an issue in the pages directory where a file named _url.vue is located. The contents of this file are as follows: <template lang="pug"> div component( v-for= ...

Express.js, Pug.js, and Webpack: A powerful trio

I am working on a Node js server app that utilizes Express and Pug. My goal is to bundle it into a single script for deployment using pm2. However, I have encountered a few issues along the way. During runtime, I am faced with a Cannot find module "." er ...

Customizing the Steps Component in Ant Design

Currently, I am utilizing the Steps component from Ant Design. My goal is to enhance its functionality by adding additional components, like a button placed next to each step's description to make it more interactive. Furthermore, I am looking to inc ...

Having trouble transforming the JSON object into a usable format

Although I'm still getting the hang of JSON, please bear with me if this seems like a rookie mistake. My approach involves sending a query to a local file that performs a cURL operation on an external site's API and returns a JSON object. Due to ...

Click on the button to send the input field

Below you'll find an input field and a button: <input id="pac-input" class="controls" type="text" placeholder="Search! e.g. Pizza, Pharmacy, Post office"> <button id="new" class="btn btn-success">Submit</button> Currently, when te ...

When the submit button is clicked, only the last form within the function will be submitted

I currently have a submit button that is meant for 3 different forms. When submitting, I use the following approach: restaurantCreateForm = function(){ document.getElementById("restaurant-features" ).submit(); document.getElementById("information_ ...

AngularJS modules are not loading dependencies such as constants or controllers

While searching for the reason why a properly defined factory is not loading, I came across this question. This led me to contemplate on the concept of services being "defined in an angular module". Consider this example: angular.module('d3', ...

Utilizing Element IDs for JQuery Tab Implementation

Having two buttons and two divs with paragraphs, I want to create tabs without adding new classes or IDs. Can I achieve tab switching using the existing IDs that end with "_one"? For instance: The first button has the ID "tab_button_one" and the first di ...

Exploring the secure synergy between Laravel 5.5 Passport client_secret and Vue JS authentication

Greetings to all, Currently, I am delving into the world of Laravel Passport and Vue.JS (standalone) simultaneously. In my authentication process, I am utilizing the Password Grant Token. An issue that has come up is the necessity for keeping the secret_ ...

Upon loading the page, trigger the controller method by utilizing the information from the query string

Can query string data be retrieved on page load with javascript? Here is how I am attempting to achieve this in my project: The view page displays tabular data. When a button is pressed, it retrieves the row's id and invokes a javascript function. ...

Displaying hidden Divs in React Typescript that are currently not visible

I have an array with various titles ranging from Title1 to Title8. When these titles are not empty, I am able to display their corresponding information successfully. Now, my goal is to include a button that will allow me to show all fields. For example, ...

"Troubleshooting: Why is my AngularJS ng-click not triggering the function

My custom directive fetches a navigation block from a webservice call. I am attempting to click on a navigation link that has an "ng-click" attribute set, which should call the specified function. However, the function is not being executed. Below is my r ...

React/MaterialUI - Is there a way to customize the placeholder text for my multi-input field beyond the provided options?

I have a dropdown menu that accepts two JSON objects, symbol and company. export default function SymbolInput() { const [data, setData] = useState({ companies: [] }); const classes = useStyles(); useEffect(() => { Axios.get(" ...

How to upload a multipart form with JSON and file using Dojo's XHR functionality

I've been struggling to find a solution for this issue. The closest I found was a thread on Stack Overflow about composing multipart/form-data with different Content-Types, but it didn't fully address my problem. Here's the situation - I ha ...

Retrieve pairs of items from a given variable

Containing values in my 'getDuplicates' variable look like this: getDuplicates = 100,120,450,490,600,650, ... These represent pairs and ranges: Abegin,Aend,Bbegin,Bend My task is to loop through them in order to apply these ranges. var ge ...

Using infoWindows with multiple markers in Google Maps

i have developed a custom Google Maps application that pulls data from a CSV file. The functionality works well, but I am facing an issue with the infoWindow when looping through all the objects. It seems like the problem stems from the marker variable bei ...

Error EADDRINUSE occurring consistently when invoking AWS Lambda functions

I set up a Node.js AWS Lambda function that was working perfectly fine through API Gateway until yesterday. Strangely, without any changes on my end, it has stopped functioning. Every time I try to trigger the function, it abruptly terminates with the fol ...

Looking for a way to trigger a function on JSTree's refresh event

I have searched through many posts here but cannot find what I am looking for. The version of JSTree that I am using is 3.3.3. My goal is to select a node after a create_node event triggers an AJAX request. Subsequently, JSTree fires the rename_node eve ...