Answer the question
In order to leave comments, you need to log in
How to work with API written in php from node.js?
Our project has an API written in php for working with a database.
In order to prepare the database for testing, the programmers have added several methods so that we (the testers) do not write the queries themselves, but pull the API methods.
Run example:
Entry point URL " https://api.mystend.domain.zone/jsonRpc "
Query according to JsonRpc standard.
We write tests in js.
If for direct requests I would use node-mysql, then here I have no idea from which side to approach the task, which package to download, and whether it is even possible to implement in js work with API methods written in php. I hear about Json-rpc for the first time.
Tell me, pliz, where to start?
Answer the question
In order to leave comments, you need to log in
JsonRpc is just a buzzword for under-REST (well, or re-REST) over http.
Install superagent via npm and go:
request
.get('https://api.mystend.domain.zone/jsonRpc')
.send({ query: 'dogById', id: '13' }) /* тут вот некий объект, описывающий запрос согласно спецификации, которую вам должны предоставить разработчики вашего "JsonRpc" */
.set('X-API-Key', 'foobar') // Ну и заголовочки (авторизация там может или еще что)
.set('Accept', 'application/json')
.end(function(err, res) { // Тут ответ этого самого JsonRpc
expect(res.dogName).toEqual('Brownie');
});
The decision from Alexander Marchenko is correct, the error was because the stand was assembled with the wrong branch ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question