How to search by id in Mockable.io? - javascript

I created a mock service using mockable.io.
For example:
Putting this in the url works:
http://demo#####.mockable.io/items
But if I filter it with:
http://demo#####.mockable.io/items?pid=5
It doesn't work as it should, it shows all the data instead of filtering them.
Can anyone tell me what I'm doing wrong please?

Mockable is in beta and I suspect they haven't sorted all the kinks out yet, I have the same problem when using it. An alternative is Sandbox - you can script mock service behaviour and can handle query parameters any way you like (disclaimer: I'm a founder)

I just tested your scenario and it works in my space.
Maybe you inverted the responses between the 2 mocks ?
You should send a support request to the mockable.io team. They are very active and will help you.

I solved it using filter.
Example: /blogs?filter=blog1
Documentation link: https://www.mockapi.io/docs
SEARCHING & FILTERING
Add query params to GET request:
/blogs?search=blog1
/blogs?filter=blog1
/blogs?title=cool%20blog

Related

Image4io and NodeJS: Documentation is clearly outdated. How do I upload an image?

I guess this is as much a call to attention on the fact that the documentation seems to be outright incorrect in its application, as well as just generally lacking. Normally, I would send that part of the message to them personally, but, their contact form is also giving me errors and not sending, so it's not like I have the means to anyway. In the mean time, I'm more worried about getting this code to work, so hopefully someone experienced with this SDK or an Image4io team member sees this and can provide a public answer for others stumbling into this road block.
For starters, I initialized the Image4io object as described in the github here: https://github.com/Image4IO/image4ionodeSDK/
website documentation: https://image4.io/en/documentation/api-sdk/#operation/UploadImage
The image upload example provided on the website's documentation looks like this:
let client=new Image4ioAPI.Image4ioAPI(apiKey,apiSecret);
var request = new Models.UploadImagesRequest("/folderName", true, true);
request.Add("/path/to/image/location/name-of-the-image.jpg", "name-of-the-image", "name-of-the-image.jpg");
let response=client.UploadImage(request);
3 out of the very sparse 4 lines of code they provide give errors. Where did this Models object come from? There is no corresponding class in the import and the code example obviously doesn't show where it was defined. Just what is it and where did it come from?
Well, I found a matching function "UploadImagesRequest" in the original import class, so my guess is Models was deprecated and its functionality was moved into the Image4io class object. If that was the case the solution would be to simply access that function instead... But it's not used the same. It has 4 arguments, the 4th being a "Image4io.UploadFile[]" type. This type has no use examples in the documentation or further details describing what it is exactly. I assume image byte data goes in there somehow, but how?
Finally we have request.Add... except we don't because that isn't a function :( it looks like this was used to actually get the image data (maybe of the type UploadFile?) based on the path of the image. If this function is gone now, how do get file data for use in the upload request function?
Any and all help in figuring out this SDK would be greatly appreciated. Google searches yielded no meaningful results, so hopefully we can help in that department as well. For all I know I just got the wrong version somehow. I guess I could try downgrading to a version that matches the documentation but... that's not a fix in my eyes at all.
Let me know if there's any more info I could provide to help
You can upload image like this:
var client=new Image4ioClient(API_KEY,API_SECRET);
var files=Array();
files.push(new UploadFile("./test.jpg","test.jpg"));
client.UploadImage(new UploadImagesRequest("/",true,false,files))
.then(res=>console.log(res))
If you have binary data at hand, you can write it to a temporary file and then upload them.

AZDO Release Pipeline Gate Success Criteria for Rest-API

I am trying to use the Release Pipeline Gate feature using an Invoke REST API. I am getting the Response successfully, however, I have issues with the success criteria.
The result I am getting from the API Call:
{"projectStatus":{"status":"NONE","conditions":[],"periods":[]}}
Now the issue I am having is with setting up the criteria. If it was per say only {"status":"NONE","conditions":[],"periods":[]} it would've been easy as eq(root['#status'], 'NONE') would've worked, but what can I do in the case above?
I've tried absolutely everything and nothing works. I've followed a lot of examples but I couldn't find an example like this one.
Could you please assist?
After many tests, I managed to find the solution:
eq(jsonpath('$.projectStatus.status')[0],'NONE')
Works flawlessly...

Why expected route does not add item to models collection using sails.js blueprint API

Quick question for anyone that can help relating to adding an item to a models collection. (eg: Adding a tag to a blog post. Many to Many relationship) Doing this through a REST API call with default blueprints.
This works: http://host/blogpost/1/tag/add/2
however I would expect this to work: http://host/blogpost/1/tag/2
Instead it gives a 404 not found.
Thanks
Spencer
OK, thanks to #japel in the sails chat room for pointing out that there is no route for the second option. In fact now that I think about it, how else would the blueprint know if I want to add or remove an item without specifying the keyword, although perhaps changing from a POST to a DELETE could work. The comments in the docs for the blueprint API add method are somewhat misleading: http://sailsjs.org/documentation/reference/blueprint-api/add-to
For now I can live with specifying the action in the route.

angular ngRoute breaks when using base tag

Can anyone tell me what is wrong with my code? I put up a simple webpage to show you: http://plnkr.co/edit/TkADpfgchYVdvNTqRPFT?p=preview
I'm using base tag with a sub dir along with html5mode and the beta version
I don't think you're really doing anything wrong. I think its a bug in the new release candidate. You're not really even doing anything special. Its just in your $locationProvider.html5Mode(true); call. That function calls angular's beginsWith function, which calls .indexOf on the url string, which is apparently undefined. I would suggest creating a bug for it on angular's github page. You can do that here. I would simply post this issue and the link to your plunker and they should be able to handle it.
That's precisely why they ask us to test the rc's. Good find. I'm not actually using HTML5Mode, so I hadn't found this particular bug yet.
You are trying to call a method of an undefined variable. You should probably add a check such as:
if (typeof variable ==="undefined")

What is $cacheFactory?

I can find absolutely no information on what exactly $cacheFactory is and how it can be useful in your application.
The Angular Documentation says
"Factory that constructs cache objects and gives access to them." -- $cacheFactory
Well, that wasn't at all helpful, what does that mean? There doesn't seem to be anything on Google either.
Can someone please explain What it is & When can it be useful.
Thanks in advance.
Oh the $cacheFactory is simple as i understand it :
If you have a request to retrieve constant data for example like a list of cities.
It's not a good pattern to get this list from the server each time the user go on a form where he has to select a city !
So you have to cache this list. The cacheFactory is done for that !
If you're using $http instead of $resource you can enbale the cache just like that :
$http.get('myUrl', { cache: true })

Categories

Resources