How do i make the requests?

|
senhorY 2019-04-24 21:11:53
Am I right?
2019-04-24 21:12:42
Does anyone know ,what to do if someone hacked your website, and after removing all the files, how hacker generating index file
Hfally 2019-04-24 21:14:34
senhorY 2019-04-24 21:11:37
I mean you could include the csrf_token right inside the js

Oh well, yeah you can tho. I use d meta tag in order to be able to call that particular token anywhere in my js file, even if its not ajax, lol…

But, yh that is also a very valid way nd saves code

Hfally 2019-04-24 21:14:48
senhorY 2019-04-24 21:11:53
Am I right?

Perfectly right

SkipperStrange 2019-04-24 21:15:43
senhorY 2019-04-24 21:11:37
I mean you could include the csrf_token right inside the js

That’s what I tried at first

SkipperStrange 2019-04-24 21:16:02
Couldn’t figure out what went wrong
senhorY 2019-04-24 21:16:55
SkipperStrange 2019-04-24 21:15:43
That’s what I tried at first

Try the passport:key thing now that you have it installed

SkipperStrange 2019-04-24 21:17:18
SkipperStrange 2019-04-24 21:16:02
Couldn’t figure out what went wrong

I added it as _token: {{csfr_token}} to the payload

senhorY 2019-04-24 21:18:02
php artisan passport:key
senhorY 2019-04-24 21:19:30
SkipperStrange 2019-04-24 21:17:18
I added it as _token: {{csfr_token}} to the payload

You’re missing the parenthesis btw

SkipperStrange 2019-04-24 21:19:43
Ok
SkipperStrange 2019-04-24 21:20:07
I’ll try that without the $.ajaxSetup();
senhorY 2019-04-24 21:20:35
$.ajax({
type: “POST”,
url: “/endpoint”,
data: {‘_token’: “{{ csrf_token()}} “},
dataType: ‘JSON’,
success: function (data) {
console.log(data);
}
})
senhorY 2019-04-24 21:20:42
In a blade template
Hfally 2019-04-24 21:21:40
SkipperStrange 2019-04-24 21:20:07
I’ll try that without the $.ajaxSetup();

Ok bro, however, this is a global setup, hence you wont need to send _token anymore anywhere you’re making an ajax call

senhorY 2019-04-24 21:22:23
I also think it’s better to set up the headers
senhorY 2019-04-24 21:22:41
That’s what laravel does in the first place
senhorY 2019-04-24 21:23:57
laravel/bootstrap.js at master · laravel/laravel · GitHub
https://github.com/laravel/laravel/blob/master/resources/js/bootstrap.js

laravel/laravelGitHub
A PHP framework for web artisans. Contribute to laravel/laravel development by creating an account on GitHub.
senhorY 2019-04-24 21:24:30
Line 35
StanleyMasinde 2019-04-24 21:24:44
Guys if you are using laravel.
You don’t need to go through all that….

If you open resources/js/bootstrap.js

You’ll find axios already setup for you.
Use axuis library for your ajax requests.

SkipperStrange 2019-04-24 21:25:26
StanleyMasinde 2019-04-24 21:24:44
Guys if you are using laravel.
You don’t need to go through all that….

If you open resources/js/bootstrap.js

You’ll find axios already setup for you.
Use axuis library for your ajax requests.

As i Twitter bootstrap js??

senhorY 2019-04-24 21:25:31
StanleyMasinde 2019-04-24 21:24:44
Guys if you are using laravel.
You don’t need to go through all that….

If you open resources/js/bootstrap.js

You’ll find axios already setup for you.
Use axuis library for your ajax requests.

But he’s using jquery

StanleyMasinde 2019-04-24 21:25:45
senhorY 2019-04-24 21:25:31
But he’s using jquery

It will still work

senhorY 2019-04-24 21:26:17
If he wants to use axios, yes
StanleyMasinde 2019-04-24 21:26:42
senhorY 2019-04-24 21:26:17
If he wants to use axios, yes

Yeah and axios is a modern library with promises

StanleyMasinde 2019-04-24 21:26:55
SkipperStrange 2019-04-24 21:25:26
As i Twitter bootstrap js??

No

SkipperStrange 2019-04-24 21:27:06
StanleyMasinde 2019-04-24 21:24:44
Guys if you are using laravel.
You don’t need to go through all that….

If you open resources/js/bootstrap.js

You’ll find axios already setup for you.
Use axuis library for your ajax requests.

How do i make the requests?

senhorY 2019-04-24 21:27:26
I totally agree, but I suppose he’s comfortable using jquery’s ajax
SkipperStrange 2019-04-24 21:27:28
Should i load to my master blad template?
SkipperStrange 2019-04-24 21:27:48
Whichever ever works
StanleyMasinde 2019-04-24 21:27:55
SkipperStrange 2019-04-24 21:27:06
How do i make the requests?

Just like jquery.

axios.post()
Etc.

It supports all methods including put and delete

SkipperStrange 2019-04-24 21:28:25
Same parameters?
StanleyMasinde 2019-04-24 21:28:29
SkipperStrange 2019-04-24 21:27:28
Should i load to my master blad template?

Just load the app.js it has axios compiled via webpack

StanleyMasinde 2019-04-24 21:28:34
SkipperStrange 2019-04-24 21:28:25
Same parameters?

Yes

senhorY 2019-04-24 21:29:47
If you want to use axios you can do it like this: axios.get(‘endpoint’)
senhorY 2019-04-24 21:30:06
Or post or whatever
StanleyMasinde 2019-04-24 21:30:56
laravel_discuss-5160.jpg
This is an example
StanleyMasinde 2019-04-24 21:31:29
senhorY 2019-04-24 21:30:06
Or post or whatever

Just like in jQuery

senhorY 2019-04-24 21:32:18
Easier in my opinion
senhorY 2019-04-24 21:32:41
It’s been ages since I quit using jquery
StanleyMasinde 2019-04-24 21:32:48
laravel_discuss-5164.jpg
For post just like jquery
senhorY 2019-04-24 21:33:40
I’m making a shirt right now
StanleyMasinde 2019-04-24 21:33:44
For debugging 😂😂
senhorY 2019-04-24 21:34:20
The good ole alert
StanleyMasinde 2019-04-24 21:34:33
😂 that is how real men debug. Only kids use a debugger
senhorY 2019-04-24 21:35:38
That sentence deserves another shirt to be printed
senhorY 2019-04-24 21:37:46
Skipper did it work?
SkipperStrange 2019-04-24 22:00:33
Sorry had a call
SkipperStrange 2019-04-24 22:00:44
Trying it now
SkipperStrange 2019-04-24 22:01:27
I loaded my own app.js file so m including default laravel app.js now
|