Coder Social home page Coder Social logo

Comments (4)

mlantz avatar mlantz commented on June 12, 2024

To do an AJAX request with the user already logged in you dont need JWT. JWT is designed for apps that have a completely separated front-end to backend example: Single Page Applications that need to authenticate with an API. Ember is a great JavaScript framework for that.

Based on what I'm seeing you're trying to send the _token as an Authorization header. If you're using the _token that is defined by default thats the CSRF token so you need to adjust your request as follows:

<input type="hidden" v-model="activity._token" value="window._token">

				axios.post('/api/v1/activities', this.activity)
                                 .then((res) => { console.log(res); })
                                 .catch((err) => { console.error(err); })
          
			}```

Then in the `master.blade.php` file you'll need to adjust the `_token` to `window._token` that should work then. 

from builder.

connor11528 avatar connor11528 commented on June 12, 2024

Okay thank you for the explanation of using JWT. I think it's going to be easier to use the CRUD Maker pattern and similar type forms.

I spun up a new Grafite app to test the CRUD Maker and ran into an issue where in ActivateService:sendActivationToken auth()->user()->meta is evaluating to null, after I ran the seeder.

Do you know why the meta relationship comes up null after running the seeder? (If this is better as a separate issue I can open it that way)

from builder.

mlantz avatar mlantz commented on June 12, 2024

Off the top of my head no, you'd have to check your database and confirm that that relationship exists.

from builder.

connor11528 avatar connor11528 commented on June 12, 2024

All good! Appreciate the help. I'm simplifying it by adding activities the old fashion way:

<form method="POST" action="/activities">
    {{ csrf_field() }}
    <input type="date" class="form-control" name="date">
    <input type="text" class="form-control" name="title">
    <input type="submit" value="Add Activity" class="btn btn-primary">
</form>

Down the line I'll get more comfortable with API interactions and the CRUD Maker. Awesome tool!

from builder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.