No response data from Laravel API using AxiosAdding Access-Control-Allow-Origin header response in Laravel 5.3 PassportCORS Issue with external API - Works via PostMan but not HTTP request with AxiosCapture error from laravel controller with AxiosHow to delete multiple rows using checkbox in Laravel 5.5 + Vue.js + AxiosHow to set Session using Axios in Vue.js and LaravelVue axios (and fetch) responses not passing into data propertyDownloading Excel data using Axios from Laravel backend is not workingAxios PUT works in Chrome and Firefox but not in SafariLaravel + vueJs + axios, bearer token not workingChange responseType in Axios based on responseRequest has data but axios not reading
Part of my house is inexplicably gone
Can a non-diagonal 2x2 matrix with just one eigenvalue be diagonalizable?
Is it good practice to create tables dynamically?
Dedicated bike GPS computer over smartphone
Must I use my personal social media account for work?
Someone who is granted access to information but not expected to read it
Nth term of Van Eck Sequence
Why did Robert pick unworthy men for the White Cloaks?
How do I type a hyphen in iOS 12?
Can an escape pod land on Earth from orbit and not be immediately detected?
How can religions without a hell discourage evil-doing?
How to represent jealousy in a cute way?
How to make this Scala method return the same generic as the input?
Do gold quality wild crops yield better seeds?
usage of mir gefallen
What did the 8086 (and 8088) do upon encountering an illegal instruction?
Manager wants to hire me, HR do not, how to proceed?
Class A Amplifier Design: Emitter Resistance Voltage Drop
Fully extended TQFT and lattice models
How was nut milk made before blenders?
Why is it bad to use your whole foot in rock climbing
Is it true that "only photographers care about noise"?
I sent an angry e-mail to my interviewers about a conflict at my home institution. Could this affect my application?
Why would a car salesman tell me not to get my credit pulled again?
No response data from Laravel API using Axios
Adding Access-Control-Allow-Origin header response in Laravel 5.3 PassportCORS Issue with external API - Works via PostMan but not HTTP request with AxiosCapture error from laravel controller with AxiosHow to delete multiple rows using checkbox in Laravel 5.5 + Vue.js + AxiosHow to set Session using Axios in Vue.js and LaravelVue axios (and fetch) responses not passing into data propertyDownloading Excel data using Axios from Laravel backend is not workingAxios PUT works in Chrome and Firefox but not in SafariLaravel + vueJs + axios, bearer token not workingChange responseType in Axios based on responseRequest has data but axios not reading
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am setting up authentication using Laravel (Laravel Framework version 5.8.4) as a REST API, but when I make a post request using Axios, I get back an empty string.
Here is my code in Laravel: "login" endpoint in my main controller:
class MainController extends Controller
public function login(Request $request)
$data = [
'message' => 'yo'
];
return Response::json($data, 200);
Here is my Axios code (from Vue.js method):
methods:
submitRegistration: function()
axios.post('http://envelope-api.test/api/auth/login',
name: this.form.name,
email: this.form.email,
password: this.form.password,
password_confirmation: this.form.password_confirmation
)
.then(function (response)
console.log("here's the response")
console.log(response);
)
.catch(function (error)
console.log(error);
);
,
Here is the response from Postman (it works!)
"message": "yo"
Here is the response from my axios request in console (empty string, where's the data?) :
data: "", status: 200, statusText: "OK", headers: …, config: …, …
laravel axios postman
|
show 1 more comment
I am setting up authentication using Laravel (Laravel Framework version 5.8.4) as a REST API, but when I make a post request using Axios, I get back an empty string.
Here is my code in Laravel: "login" endpoint in my main controller:
class MainController extends Controller
public function login(Request $request)
$data = [
'message' => 'yo'
];
return Response::json($data, 200);
Here is my Axios code (from Vue.js method):
methods:
submitRegistration: function()
axios.post('http://envelope-api.test/api/auth/login',
name: this.form.name,
email: this.form.email,
password: this.form.password,
password_confirmation: this.form.password_confirmation
)
.then(function (response)
console.log("here's the response")
console.log(response);
)
.catch(function (error)
console.log(error);
);
,
Here is the response from Postman (it works!)
"message": "yo"
Here is the response from my axios request in console (empty string, where's the data?) :
data: "", status: 200, statusText: "OK", headers: …, config: …, …
laravel axios postman
post your axios call code
– Ashley Brown
Mar 25 at 0:31
and your route in php
– Ashley Brown
Mar 25 at 0:31
post it in your question, press edit
– Ashley Brown
Mar 25 at 0:42
ok, just updated code @AshleyBrown
– Tony Brackins
Mar 25 at 0:48
If you open the whole console.log in the inspector, can you see the message? Try yo doconsole.log(response.message)
– Jacobo Tapia
Mar 25 at 1:13
|
show 1 more comment
I am setting up authentication using Laravel (Laravel Framework version 5.8.4) as a REST API, but when I make a post request using Axios, I get back an empty string.
Here is my code in Laravel: "login" endpoint in my main controller:
class MainController extends Controller
public function login(Request $request)
$data = [
'message' => 'yo'
];
return Response::json($data, 200);
Here is my Axios code (from Vue.js method):
methods:
submitRegistration: function()
axios.post('http://envelope-api.test/api/auth/login',
name: this.form.name,
email: this.form.email,
password: this.form.password,
password_confirmation: this.form.password_confirmation
)
.then(function (response)
console.log("here's the response")
console.log(response);
)
.catch(function (error)
console.log(error);
);
,
Here is the response from Postman (it works!)
"message": "yo"
Here is the response from my axios request in console (empty string, where's the data?) :
data: "", status: 200, statusText: "OK", headers: …, config: …, …
laravel axios postman
I am setting up authentication using Laravel (Laravel Framework version 5.8.4) as a REST API, but when I make a post request using Axios, I get back an empty string.
Here is my code in Laravel: "login" endpoint in my main controller:
class MainController extends Controller
public function login(Request $request)
$data = [
'message' => 'yo'
];
return Response::json($data, 200);
Here is my Axios code (from Vue.js method):
methods:
submitRegistration: function()
axios.post('http://envelope-api.test/api/auth/login',
name: this.form.name,
email: this.form.email,
password: this.form.password,
password_confirmation: this.form.password_confirmation
)
.then(function (response)
console.log("here's the response")
console.log(response);
)
.catch(function (error)
console.log(error);
);
,
Here is the response from Postman (it works!)
"message": "yo"
Here is the response from my axios request in console (empty string, where's the data?) :
data: "", status: 200, statusText: "OK", headers: …, config: …, …
laravel axios postman
laravel axios postman
edited Mar 25 at 1:28
Tony Brackins
asked Mar 25 at 0:29
Tony BrackinsTony Brackins
2614
2614
post your axios call code
– Ashley Brown
Mar 25 at 0:31
and your route in php
– Ashley Brown
Mar 25 at 0:31
post it in your question, press edit
– Ashley Brown
Mar 25 at 0:42
ok, just updated code @AshleyBrown
– Tony Brackins
Mar 25 at 0:48
If you open the whole console.log in the inspector, can you see the message? Try yo doconsole.log(response.message)
– Jacobo Tapia
Mar 25 at 1:13
|
show 1 more comment
post your axios call code
– Ashley Brown
Mar 25 at 0:31
and your route in php
– Ashley Brown
Mar 25 at 0:31
post it in your question, press edit
– Ashley Brown
Mar 25 at 0:42
ok, just updated code @AshleyBrown
– Tony Brackins
Mar 25 at 0:48
If you open the whole console.log in the inspector, can you see the message? Try yo doconsole.log(response.message)
– Jacobo Tapia
Mar 25 at 1:13
post your axios call code
– Ashley Brown
Mar 25 at 0:31
post your axios call code
– Ashley Brown
Mar 25 at 0:31
and your route in php
– Ashley Brown
Mar 25 at 0:31
and your route in php
– Ashley Brown
Mar 25 at 0:31
post it in your question, press edit
– Ashley Brown
Mar 25 at 0:42
post it in your question, press edit
– Ashley Brown
Mar 25 at 0:42
ok, just updated code @AshleyBrown
– Tony Brackins
Mar 25 at 0:48
ok, just updated code @AshleyBrown
– Tony Brackins
Mar 25 at 0:48
If you open the whole console.log in the inspector, can you see the message? Try yo do
console.log(response.message)
– Jacobo Tapia
Mar 25 at 1:13
If you open the whole console.log in the inspector, can you see the message? Try yo do
console.log(response.message)
– Jacobo Tapia
Mar 25 at 1:13
|
show 1 more comment
2 Answers
2
active
oldest
votes
To get data from axios
you should use response.data
, not just response
.
Edit: Try to respond with the helper.
response()->json($data);
Hisdata
seems empty though :/
– senty
Mar 25 at 1:11
I've updated my answer.
– Benjamin Beganović
Mar 25 at 1:12
add a comment |
I've got this figured out. Thanks for your help.
I had this chrome extension installed to allow CORS (Cross Origin Resource Sharing) so I could do API requests from localhost (apparently, not needed for Postman?).
I turned it off and installed it locally on Laravel using this post (answer from naabster)
After I installed this way, it worked regularly.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329924%2fno-response-data-from-laravel-api-using-axios%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
To get data from axios
you should use response.data
, not just response
.
Edit: Try to respond with the helper.
response()->json($data);
Hisdata
seems empty though :/
– senty
Mar 25 at 1:11
I've updated my answer.
– Benjamin Beganović
Mar 25 at 1:12
add a comment |
To get data from axios
you should use response.data
, not just response
.
Edit: Try to respond with the helper.
response()->json($data);
Hisdata
seems empty though :/
– senty
Mar 25 at 1:11
I've updated my answer.
– Benjamin Beganović
Mar 25 at 1:12
add a comment |
To get data from axios
you should use response.data
, not just response
.
Edit: Try to respond with the helper.
response()->json($data);
To get data from axios
you should use response.data
, not just response
.
Edit: Try to respond with the helper.
response()->json($data);
edited Mar 25 at 1:12
answered Mar 25 at 1:09
Benjamin BeganovićBenjamin Beganović
26616
26616
Hisdata
seems empty though :/
– senty
Mar 25 at 1:11
I've updated my answer.
– Benjamin Beganović
Mar 25 at 1:12
add a comment |
Hisdata
seems empty though :/
– senty
Mar 25 at 1:11
I've updated my answer.
– Benjamin Beganović
Mar 25 at 1:12
His
data
seems empty though :/– senty
Mar 25 at 1:11
His
data
seems empty though :/– senty
Mar 25 at 1:11
I've updated my answer.
– Benjamin Beganović
Mar 25 at 1:12
I've updated my answer.
– Benjamin Beganović
Mar 25 at 1:12
add a comment |
I've got this figured out. Thanks for your help.
I had this chrome extension installed to allow CORS (Cross Origin Resource Sharing) so I could do API requests from localhost (apparently, not needed for Postman?).
I turned it off and installed it locally on Laravel using this post (answer from naabster)
After I installed this way, it worked regularly.
add a comment |
I've got this figured out. Thanks for your help.
I had this chrome extension installed to allow CORS (Cross Origin Resource Sharing) so I could do API requests from localhost (apparently, not needed for Postman?).
I turned it off and installed it locally on Laravel using this post (answer from naabster)
After I installed this way, it worked regularly.
add a comment |
I've got this figured out. Thanks for your help.
I had this chrome extension installed to allow CORS (Cross Origin Resource Sharing) so I could do API requests from localhost (apparently, not needed for Postman?).
I turned it off and installed it locally on Laravel using this post (answer from naabster)
After I installed this way, it worked regularly.
I've got this figured out. Thanks for your help.
I had this chrome extension installed to allow CORS (Cross Origin Resource Sharing) so I could do API requests from localhost (apparently, not needed for Postman?).
I turned it off and installed it locally on Laravel using this post (answer from naabster)
After I installed this way, it worked regularly.
answered Mar 25 at 1:36
Tony BrackinsTony Brackins
2614
2614
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329924%2fno-response-data-from-laravel-api-using-axios%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
post your axios call code
– Ashley Brown
Mar 25 at 0:31
and your route in php
– Ashley Brown
Mar 25 at 0:31
post it in your question, press edit
– Ashley Brown
Mar 25 at 0:42
ok, just updated code @AshleyBrown
– Tony Brackins
Mar 25 at 0:48
If you open the whole console.log in the inspector, can you see the message? Try yo do
console.log(response.message)
– Jacobo Tapia
Mar 25 at 1:13