brillout / wildcard-api

Functions as API.
MIT License
369 stars 14 forks source link

Using postman to test endpoints #37

Closed worms19 closed 4 years ago

worms19 commented 4 years ago

Hey,

i tried to create endpoints with arguments :

the http request in the request look like this :

Request URL: http://localhost:8000/wildcard/deleteEducationObject/%5B123%5D

i'm trying to use PostMan to test the requests, what documentation should i check to see how url are constructed ?

thanks again

brillout commented 4 years ago

Hi @worms19,

You can test by using the Wildcard client:

// Node.js

// The Wildcard client works in Node.js as welll
const {endpoints} = require('@wildcard-api/client');

[testDelete, test2].forEach(test => test());

async function testDelete() {
  const id = 123;
  await endpoints.addEducationObject({id, title: "Learn about ..."});
  let educationObjects = await endpoints.getAllEducationObjects();
  assert(educationObjects.some(obj => obj.id===id));
  await endpoints.deleteEducationObject(id);
  educationObjects = await endpoints.getAllEducationObjects();
  assert(!educationObjects.some(obj => obj.id===id));
}

function test2() {
  /* another test */
}

Does that work for you?

Wildcard aims to fully abstract away anything related to HTTP and serialization; you shouldn't have to know about these things. If you're curious how things work I'm happy to elaborate :-)

Rom

brillout commented 4 years ago

Feel free to re-open if this is still an issue and/or if you have questions :-).