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;








0















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: …, …









share|improve this question
























  • 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


















0















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: …, …









share|improve this question
























  • 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














0












0








0








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: …, …









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 do console.log(response.message)

    – Jacobo Tapia
    Mar 25 at 1:13


















  • 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

















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













2 Answers
2






active

oldest

votes


















0














To get data from axios you should use response.data, not just response.



Edit: Try to respond with the helper.



response()->json($data);






share|improve this answer

























  • His data seems empty though :/

    – senty
    Mar 25 at 1:11











  • I've updated my answer.

    – Benjamin Beganović
    Mar 25 at 1:12


















0














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.






share|improve this answer























    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
    );



    );













    draft saved

    draft discarded


















    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









    0














    To get data from axios you should use response.data, not just response.



    Edit: Try to respond with the helper.



    response()->json($data);






    share|improve this answer

























    • His data seems empty though :/

      – senty
      Mar 25 at 1:11











    • I've updated my answer.

      – Benjamin Beganović
      Mar 25 at 1:12















    0














    To get data from axios you should use response.data, not just response.



    Edit: Try to respond with the helper.



    response()->json($data);






    share|improve this answer

























    • His data seems empty though :/

      – senty
      Mar 25 at 1:11











    • I've updated my answer.

      – Benjamin Beganović
      Mar 25 at 1:12













    0












    0








    0







    To get data from axios you should use response.data, not just response.



    Edit: Try to respond with the helper.



    response()->json($data);






    share|improve this answer















    To get data from axios you should use response.data, not just response.



    Edit: Try to respond with the helper.



    response()->json($data);







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 25 at 1:12

























    answered Mar 25 at 1:09









    Benjamin BeganovićBenjamin Beganović

    26616




    26616












    • His data 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











    • 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













    0














    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.






    share|improve this answer



























      0














      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.






      share|improve this answer

























        0












        0








        0







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 1:36









        Tony BrackinsTony Brackins

        2614




        2614



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현