Help

No API response, but creates record

Topic Labels: API
1298 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Natasha_Wong
4 - Data Explorer
4 - Data Explorer

Hello,

I have an Express POST route that creates a record. When I test the API, it successfully creates the record populated with all the right info (I checked the table). However, I receive no response from the API (Postman times out, and in the console I get - - ms - -).

Here’s a snippet of my Express POST call.

router.post('/submitimportedorders', (req, res) => {
  importedCarOrdersTable.create(req.body,
    function(err) {
      if (err) {console.error(err);}
  });
})

Would love some help with this. I can also provide more code if required.

1 Reply 1
Mike_Pennisi
7 - App Architect
7 - App Architect

Your API isn’t responding because there’s no code to send a response. Here’s how the communication looks visually:

        | --POST /submitimportedorders--> |          | --importedCarOrdersTable.create--> |
browser |                                 | Your API |                                    | airtable.com
        |         ?? missing ??           |          | <-----(function(err) {})()-------- |

In that “missing” part, your API needs to tell the browser that the request to airtable.com is complete and also whether or not the request was successful. In Express.js, that can be done with request.end and request.send; you can learn more about using Express in that project’s documentation:

https://expressjs.com/en/starter/basic-routing.html