MEAN stack project not support success keyword - mean-stack

success keyword not support my MEANstack project. how I fix this. please help me..
my MEANstack project controller.js file

Use then() instead of success()
For versions up to Angular v.1.6, you have to use then method. The then() method takes two arguments: a success and an error callback which will be called with a response object.
Example:
$http.get('api/url-api').then(successCallback, errorCallback);

Related

Cypress: Test non-XHR request caused by submitting POST form

I am testing Vue application. In some cases my application have to submit(not just after click submit button but programmatically) POST form and redirect to 3rd party server with some body parameters. Like in best practice written I am trying to avoid of using redirect to real server.
For my certain test it will be sufficient to just make sure that request was sent with certain parameters, but I don't now how to catch this body request parameters for assertion, because cypress does not allow to stub non-XHR requests and I can't do like this:
cy.route('POST', '/posts').as('post')
cy.get("#post").should(req => {
// check body params
});
I also thought about stub vue component method to intercept form submitting, but it only seems to work with global objects like Math.
I truly appreciate any new ideas how to test functionality like this.
Since Cypress 5.1 you can stub other requests type using cy.route2()(https://docs.cypress.io/guides/references/changelog.html#5-1-0).

Method Illuminate\Support\Str::of does not exist

I want to get data from API. But when I put the code below.
public function FUNCTION_NAME()
{
$data['title']='Title';
$data= Http::get('API_LINK')->json();
return view('user.PAGENAME', $data);
}
Then showing Method Illuminate\Support\Str::of does not exist.
How solved that
It may happen while upgrading laravel framework version of your project. Try clearing application cache, update composer, or queue:restart if it is used.
The error you are having doesn't seem to relate to the snippet you have provided.
It is complaining that the laravel sting helper Str does not have an of() method available.
You can find all of the available methods for this class in the documentation:
https://laravel.com/docs/7.x/helpers

Pass filtered data to Datatables v8 on Laravel v5.6

I have an integration with laravel datatables with elasticsearch. For the previous versions, this code was solving the issue.
return value(new CollectionEngine(collect($data), new DatatablesRequest()))
->setTotalRecords($total)
->make‌​(true);
Right now with the new version of datatables (v8) the constructor for collectionEngine has changed and no longer receives a second parameter with the request and the Yajra\DataTables\Request class has be removed as well
Still looking for a solution but with no success on this. How can I make this integration the same way I was doing it before.
Ok, didn't checked the correctly how the constructor was for the collection engine. This has been changed so it get the app request automatic so no need to be injecting new request to it. Only needs to include ->skipPaging() to the datatable.
$response = value(new CollectionEngine($data))
->skipPaging()
->make()

AJAX callback in Inter Explorer

I have a question about AJAX.. I am using AJAX for my javascript in calling php file,
how ever I noticed that when I run the program in IE callback comes in twice which
gives me more results than expected while callback comes in in firefox only once..
I want to have just the one reply from callback..
this.doPost = function(param) {
/// make a HTTP POST request to the URL synchronously
req.open("POST",url, true);
...
this is the call..
Do you know what is wrong?
Thanks.
Depending on how you actually perform the AJAX call and what you do in the callback, you can run into issues - see for example this thread for similar issues:
How to execute a page ,that contains JS ,in AJAX ,using innerHTML?
I suggest you try some proven library instead of using AJAX on the low level. For example, using jQuery you can use $.ajax, see e.g. the examples in jQuery documentation:
http://api.jquery.com/jQuery.ajax/
or some of many other examples you can find on the Net, such as this:
http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/

How to check an Ajax request in cakephp?

How to check an Ajax request in cakephp?
Depends on the version of cake.
1.3.x:
$this->RequestHandler->isAjax();
2.x || 3.x
$this->request->is('ajax');
You need to enable the RequestHandler component
var $components = array('RequestHandler');
Then you check if its an ajax request in your controllers with:
$this->RequestHandler->isAjax()
You can find more information about the RequestHandler component here
this question is an older one but just in case anyone comes across this like me and uses CakePHP 2:
RequestHandler::isAjax() is deprecated, use the Request Object's $this->request->is('ajax');
More info here
Without the use of components you can use something like this:
$this->params['isAjax'];
This will return a bool.
this is the way whisch is described is doc.I have been using since i started using cakephp
if($this->RequestHandler->isAjax()){
//
}
If you simply want to check the function of the php side, try:
$this->log('some debug',LOG_DEBUG);
then check app/tmp/logs/debug.log.

Resources