5 months ago

{message: "The POST method is not supported for this route. Supported methods: GET, HEAD.",…}

Posted 5 months ago by GrahamMorbyDev

Hey Guys

So I have an API route

Route::post('chat/post', '[email protected]');

And a controller

public function post(Request $request) {
    //Set Message Model
    $messages =  new Message();

    //Get Request params
    $message->user_id = $request['user_id'];
    $message->message = $request['message'];

    //Save to DB

    //Return Response 
    return response()->json([
      'message' => 'Message created'
    ], 201, $headers);


And im using that from

post_chat() {
      const postdata = {
        user_id: this.trade_data.user_id,
        message: this.message      };"api/chat/post", postdata, {
          headers: {
            Authorization: "Bearer " + this.api_token
        }).then(response => {

And I have now been staring at the error for over two hours and can't see why I'm getting the error

Its either going to be a typo or something completely different but any help would be wonderful

Please sign in or create an account to participate in this conversation.