Search code examples
javascriptapiloopbackjsstrongloop

Call another API from within an API


Probably the title doesn't explain what i want to achieve so i will try here.

I have an API (i am using Strongloop) through which i store some test results. Each test suite can vary in number of test cases, but at the end of a test suite, after the final result is posted, i want my API to send an OK/NOK status to another REST API.

I have a model named jobs and within this model, one key is a relation to another model, named reports, in which i save all the test results. The jobs model has only general data about the app.

My problem is that i don't know where to put the code for automatically sending the OK/NOK to the other API, after a test suite is done.

Can you advise me, please?


Solution

  • I used the request module from Brian's reply and passed the modified property using ctx.instance.propertyName.

    Thanks!