Reputation: 21
I am using PhpStorm to automate my API testing. I have a response data format like:
{"status":"OK","result":{"data":[{"id":2,"name":"store","slug":"store"},
{"id":51,"name":"store-1","slug":"store-1"},{"id":76,"name":"store-2","slug":"store-2"},
{"id":60,"name":"test-drive","slug":"Test Drive"},
{"id":52,"name":"commencal","slug":"Commencal"}]}}
From here, I want to read the name data to compare for testing API as below
client.test("check_store", function() {
client.assert(response.body.data.name=== "store", "store not found");
});
I am not sure about the format of response.body.data.name
.
Is there anyone help me to do that.
Upvotes: 1
Views: 160
Reputation: 21
I have solved the problem and want to share it with others. After writing the below statement, the problem has been resolved. response.body.result.data[0].name
Upvotes: 1