Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotFoundHttpException #181

Closed
odyright opened this issue Mar 1, 2016 · 57 comments
Closed

NotFoundHttpException #181

odyright opened this issue Mar 1, 2016 · 57 comments
Labels

Comments

@odyright
Copy link

odyright commented Mar 1, 2016

hi @jadjoubran following the tutorial V3.1, i got error: Sorry, the page you are looking for could not be found.
screen shot 2016-03-01 at 13 49 27

i checked my console and it shown:
screen shot 2016-03-01 at 13 53 39

Here is what my route.js => angular/config/Routesconfig.js looks like:

export function RoutesConfig($stateProvider, $urlRouterProvider) {
    'ngInject';

    var getView = function(viewName) {
        return './views/app/pages/' + viewName + '/' + viewName + '.html';
    };

    $urlRouterProvider.otherwise('/');

    $stateProvider
        .state('app', {
            abstract: true,
            views: {
                header: {
                    templateUrl: getView('header')
                },
                footer: {
                    templateUrl: getView('footer')
                },
                main: {}
            }
        })
        .state('app.landing', {
            url: '/',
            data: {},
            views: {
                'main@': {
                    templateUrl: getView('landing')
                }
            }
        })
        .state('app.create_post', {
            url: '/create-post',
            views: {
                'main@': {
                    templateUrl: getView('create_post')
                }
            }
      });
}

what should i do?

@jadjoubran
Copy link
Owner

Hi @odyright
I think you just need to browse to /#create-post instead of /create-post because this is an angular route..
Let me know if it works for you so I can update the docs

Thanks!

@odyright
Copy link
Author

odyright commented Mar 1, 2016

yes, i tried with & without the # before i posted, and nothing. but when i browse to /#/create-post it redirect me to the landing page

@jadjoubran
Copy link
Owner

I'm sorry I mistyped it.. could you try navigating to /#/create-post ?
Normally that's not an issue if you're using ui-sref="app.create_post" to link to a certain page

@odyright
Copy link
Author

odyright commented Mar 2, 2016

yes of course i thought of that,i tried it and retried, but same result.

<md-content class="Page-Container DemoHeader">
    <div layout="row">
        <div flex="90" flex-offset="5" class="DemoHeader-container">
            <div layout="row" layout-align="space-between">
                <img src="img/icons/logo.svg" class="DemoHeader-logo" ui-sref="app.landing"/>
                <div layout="row" layout-align="center stretch" hide-xs>
                    <a class="DemoHeader-link md-subhead" href="">Docs</a>
                    <a class="DemoHeader-link md-subhead" ui-sref="app.create_post">Create Post</a>
                </div>
            </div>
        </div>
    </div>
</md-content>

and something strange i got on my terminal, an error with a comma
screen shot 2016-03-02 at 09 34 30

@jadjoubran
Copy link
Owner

Those warnings in the terminal are fine.. they're generated by eslint.. you can think o f them as tips to improve your code.

So there are no errors in your Chrome Console when you navigate to /#/create-post?

@odyright
Copy link
Author

odyright commented Mar 2, 2016

something's wrong with my code when I type the link /#/create-post it right back to its initial state homestead.app/#/ so I can't analyse the Chrome Console

@jadjoubran
Copy link
Owner

yes even if it's redirecting, you can have the Chrome Console already open.. and just see if there are errors

@odyright
Copy link
Author

odyright commented Mar 2, 2016

hahhah i didn't know that i checked and here is what i get:
screen shot 2016-03-02 at 10 50 23

@jadjoubran
Copy link
Owner

So you can see that it wasn't able to find the template app/pages/create_post/create_post.html
Can you verify that it's there?
If not then maybe it's an issue with the generators.. so also please tell me which version you have for laravelangular/generators in your composer.json

And this assumes you've ran gulp of course

@odyright
Copy link
Author

odyright commented Mar 2, 2016

    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "tymon/jwt-auth": "0.5.*",
        "barryvdh/laravel-cors": "0.7.x",
        "laravelangular/generators": "~2.1",
        "dingo/api": "1.0.x@dev"
    },

@odyright
Copy link
Author

odyright commented Mar 2, 2016

i remember that i wasn't be able to run php artisan make:controller CreatePostController --plain instead of that i ran it without --plain. i don't think it had have an impact

@jadjoubran
Copy link
Owner

yeah --plain is now the default behavior in Laravel 5.2.. that's not the issue

Can you please do the following:

  1. run gulp - nevermind the warnings from eslint
  2. browser and verify that the following file exists: angular/app/pages/create_post/create_post.html.. if not try to find the path for this and let me know

@odyright
Copy link
Author

odyright commented Mar 2, 2016

i did gulp & yes the create_post.html file exists

@jadjoubran
Copy link
Owner

Maybe @jadsalhani has an idea?

@jadsalhani
Copy link
Collaborator

@odyright how did you create the create_post files? Through the generators or manually?

And can you show us their relative paths as well

@odyright
Copy link
Author

odyright commented Mar 2, 2016

hi @jadsalhani the create_post files has been created through the generator; here is the path: laravel5-angular-material-starter/angular/app/pages/create_post/create_post.page.html

@jadjoubran
Copy link
Owner

oh.. it's missing a .page

@odyright
Copy link
Author

odyright commented Mar 2, 2016

??? 😧 where??? pls

@jadjoubran
Copy link
Owner

so in your routes.js file, go to the getView function and change it to this:

var getView = function(viewName) {
    return './views/app/pages/' + viewName + '/' + viewName + '.page.html';
};

So it's a bug in v3.1 which hasn't been released yet.. I'm going to push a fix for that right now.
Thanks!

@jadjoubran jadjoubran added bug and removed Support labels Mar 2, 2016
@jadjoubran
Copy link
Owner

@odyright let me know if that fixes it for you

@odyright
Copy link
Author

odyright commented Mar 2, 2016

ok

@odyright
Copy link
Author

odyright commented Mar 2, 2016

errors in my chrome console:
GET http://homestead.app/views/app/pages/header/header.page.html 404 (Not Found)
GET http://homestead.app/views/app/pages/footer/footer.page.html 404 (Not Found)

@jadjoubran
Copy link
Owner

I think you had a mix of both apps because you were working on the unstable version

Open your header.html and rename it to header.page.html
same thing for the footer

@odyright
Copy link
Author

odyright commented Mar 2, 2016

i already did it before, when u post the modif. in route.js but still not working.

@jadjoubran
Copy link
Owner

okay what errors do you see?

@odyright
Copy link
Author

odyright commented Mar 2, 2016

@jadjoubran the same i mentioned.

@jadjoubran
Copy link
Owner

you can do them with components.. but it's not necessary if they don't have any logic
so what's not working right now.. I can't understand

@odyright
Copy link
Author

odyright commented Mar 2, 2016

nothing appears now
screen shot 2016-03-02 at 20 05 42

@jadjoubran
Copy link
Owner

Show me the path for your header.page.html

@jadsalhani
Copy link
Collaborator

Hi @odyright

Can you please show us the angular/app/ folder structure if it's no trouble?
As in what's inside the folders and how the pages and components are laid out

@odyright
Copy link
Author

odyright commented Mar 2, 2016

@jadjoubran the path is : laravel5-angular-material-starter/angular/app/pages/header/header.page.html

@jadsalhani here you are:
screen shot 2016-03-02 at 20 27 39

@jadjoubran
Copy link
Owner

okay and did you run gulp?
For later on you could keep gulp && gulp watch running

@odyright
Copy link
Author

odyright commented Mar 2, 2016

ok thanks @jadjoubran & @jadsalhani i restarted laravel homestead & vagrant: everything is back in order with some errors:
screen shot 2016-03-02 at 20 50 40

@odyright
Copy link
Author

odyright commented Mar 2, 2016

if i understand some value the assertion expected isn't defined. but i don't know how to fix it!

@odyright
Copy link
Author

odyright commented Mar 3, 2016

solved,
i just removed the directive ng-controller="CreatePostController as vm" I have written unintentionally in the create_post_page.html like that

<md-content class="Page-container" ng-controller="CreatePostController as vm">

    <h1>Create Post</h1>

    <create-post-form></create-post-form>

</md-content>

Now all things are right, but in another step with the form "create post" i can't save the entries in database when i tried the form, could you help me?

@jadjoubran
Copy link
Owner

Just wait for the upcoming screencasts 😄

@odyright
Copy link
Author

odyright commented Mar 3, 2016

ok i'm waiting 👍

@odyright
Copy link
Author

odyright commented Mar 6, 2016

hi @jadjoubran with the form "create post" when i tried to post something in the form i get nothing in my database, could you help me?
the Chrome console shows: POST http://homestead.app/posts 404 (Not Found)...
I don't think that this is due to "Restangular".

@antonkomarev
Copy link

Because all the requests should be done to /api/if they are created using $api in routes file.

Try to make a call to http://homestead.app/api/posts

@jadjoubran
Copy link
Owner

I think there was a mistake in the tutorial, if you're using Restangular, use API instead which is an instance of Restangular configured to work properly with this API.
I fixed it in the docs

@odyright
Copy link
Author

odyright commented Mar 7, 2016

ok thanks @a-komarev i'll try.

@jadjoubran
Copy link
Owner

@odyright the issue was in the tutorial
You can just use API instead of restangular and it'll fix it

@odyright
Copy link
Author

odyright commented Mar 7, 2016

thanks @jadjoubran i fixed it and now the console shows me :
screen shot 2016-03-07 at 11 12 46

@odyright
Copy link
Author

odyright commented Mar 7, 2016

i got : POST http://homestead.app/api/posts 500 (Internal Server Error)

@jadjoubran
Copy link
Owner

Yes it means there's an error with your backend code
If you copy pasted the code from the tutorial
You can see the errors if you click on the request in chrome

@odyright
Copy link
Author

odyright commented Mar 7, 2016

message: "Type error: Argument 1 passed to App\Http\Controllers\Controller::validate() must be an instance of Dingo\Api\Http\Request, array given, called in /home/vagrant/Code/laravel5-angular-material-starter/app/Http/Controllers/CreatePostController.php on line 14"

status_code: 500
but it seems that my CreatePostController.php is good

@jadjoubran
Copy link
Owner

please check #189
or try getting the updated code from the tutorial

@odyright
Copy link
Author

odyright commented Mar 7, 2016

ok thanks @jadjoubran i also commented the validation out and it works very well; great Tuts.
👍 But I want to know

  1. if you've put this validation it's for a purpose. Why didn't you use the angular's validation?
  2. is this with Dingo api more secure or flexible?

@odyright
Copy link
Author

odyright commented Mar 7, 2016

good i see i think that you want to do things simply such as the Dingo Api's wiki said:

Dealing with errors when building an API can be a pain. Instead of manually building error responses you can simply throw an exception that extends from Symfony\Component\HttpKernel\Exception\HttpException and the API will automatically handle the response for you.

that's great 👍

@jadjoubran
Copy link
Owner

Actually no need to comment it out if you fix the imports

  1. because validation needs to be enforced from the backend always. the front-end validation is just for the user experience

  2. It's not about security, it's about Content negotiation.. but this might be removed in the future :/ Check the content negotiation in the docs if you want to learn more

  3. and yes this has already been taken care of 😄

@odyright
Copy link
Author

odyright commented Mar 7, 2016

image ok I understand.

@odyright
Copy link
Author

odyright commented Mar 8, 2016

hi @jadjoubran
you said:

Actually no need to comment it out if you fix the imports

but I have rather done a modification of the code in the CreatePostController.php by adding $request to $this->validate(); like this:

public function create(Request $request)
    {
      $this->validate(,[
        'name'  => 'required',
        'topic' => 'required',
      ]);

      $post = new Post;
      $post->name = $request->input('name');
      $post->topic = $request->input('topic');
      $post->save();

      return response()->success(compact('post'));
    }

to

public function create(Request $request)
    {
      $this->validate($request,[
        'name'  => 'required',
        'topic' => 'required',
      ]);

      $post = new Post;
      $post->name = $request->input('name');
      $post->topic = $request->input('topic');
      $post->save();

      return response()->success(compact('post'));
    }

what do you think ?

@jadjoubran
Copy link
Owner

That's right, thanks!
I fixed the documentation and then I noticed that someone had already suggested this edit 😄
But I never received a notification :/

@odyright
Copy link
Author

odyright commented Mar 8, 2016

u're welcome even if someone suggested it before me
sees thou not that I am progressing? 💯

@jadjoubran
Copy link
Owner

Yes you are 😄 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants