dexter_siah

dexter_siah

Member Since 1 Year Ago

Experience Points
180
Total
Experience

4,820 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
180 XP
Nov
24
3 weeks ago
Activity icon

Awarded Best Reply on JSON.parse Error

Got it thanks @nakov and @tray2 . Apparently the route that was passed was report/{report}/fetchMap?id=1 instead of fetchMap?id=1. So i just changed this.

const route = `/fetchMap?id=${reportId}`;  //Added forward slash
Activity icon

Replied to JSON.parse Error

Got it thanks @nakov and @tray2 . Apparently the route that was passed was report/{report}/fetchMap?id=1 instead of fetchMap?id=1. So i just changed this.

const route = `/fetchMap?id=${reportId}`;  //Added forward slash
Activity icon

Started a new Conversation JSON.parse Error

I'm trying to use the fetch api to get my data through the controller but I'm getting an error

SyntaxError: "JSON.parse: unexpected character at line 1 column 1 of the JSON data"

The current route that is fetching the data is /report/{report} and im fetching the data from fetchMap.

JavaScript

function getId(){
    const report = document.querySelector("#reportId");
    const reportId = report.dataset.id;
    const route = `fetchMap?id=${reportId}`;

    fetchLngLat(route);
}

function fetchLngLat(route){

    fetch(route)
        .then(res => res.json())
        .then(data => {
           console.log(data);
        })
        .catch(err => console.log(err));
}

ReportController

public function fetchMap(Request $request){
    $report = Report::find($request->id);

    return response()->json($report);
}

Route

Route::get('fetchMap','[email protected]');

I have tried to dd in the fetchMap method and it does return my report when i enter the url /fetchMap?id=1 but somehow it is getting a parse error in my js script.

Any help would be appreciated

Nov
21
3 weeks ago
Activity icon

Awarded Best Reply on JS XHR Response Type Undefined

SOLVED

I managed to solved it by breaking down each parts of the XHR and i realised that it was getting the data all along just that there were no method of response.type which perhaps explains why it is undefined. When i log the response it immediately returned the array of objects to me. Here are my codes

//Get Selected Value From Options
const selectedOptions = e.target.options[e.target.selectedIndex].value

const xhr = new XMLHttpRequest();

xhr.open('GET', '{!!URL:: to('filterStatus')!!}', true);
console.log(document.head.querySelector("[name=csrf-token]").content);
xhr.setRequestHeader("X-CSRF-TOKEN", document.head.querySelector("[name=csrf-token]").content);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');


xhr.onreadystatechange = function(){
    if (xhr.readyState === 4 && xhr.status === 200)
    {
        const response = JSON.parse(this.responseText);
        response.forEach(e => {
            console.log(e.reportedBy);
        });
    }
}
xhr.send();
Activity icon

Replied to JS XHR Response Type Undefined

SOLVED

I managed to solved it by breaking down each parts of the XHR and i realised that it was getting the data all along just that there were no method of response.type which perhaps explains why it is undefined. When i log the response it immediately returned the array of objects to me. Here are my codes

//Get Selected Value From Options
const selectedOptions = e.target.options[e.target.selectedIndex].value

const xhr = new XMLHttpRequest();

xhr.open('GET', '{!!URL:: to('filterStatus')!!}', true);
console.log(document.head.querySelector("[name=csrf-token]").content);
xhr.setRequestHeader("X-CSRF-TOKEN", document.head.querySelector("[name=csrf-token]").content);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');


xhr.onreadystatechange = function(){
    if (xhr.readyState === 4 && xhr.status === 200)
    {
        const response = JSON.parse(this.responseText);
        response.forEach(e => {
            console.log(e.reportedBy);
        });
    }
}
xhr.send();
Activity icon

Replied to JS XHR Response Type Undefined

I have updated my codes to these but I am still getting undefined ... Any ideas? Any how would u suggest to separate my script from my blade file since that my url is a php syntax {{!!URL::to('filterStatus')!!}} a normal js file wouldn't understand it. Sorry if it may be a very stupid question, I'm new to laravel

const selectedOptions = e.target.options[e.target.selectedIndex].value
const csrf  = document.querySelector('input[name=_token]').value;
console.log(csrf);

const xhr = new XMLHttpRequest();

xhr.open('GET', '{!!URL:: to('filterStatus')!!}', true);
xhr.setRequestHeader('X-CSRF-TOKEN',csrf)
xhr.setRequestHeader("X-Requested-With",'XMLHttpRequest')
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");


xhr.onload = function () {
    if (this.status === 200) {
        const response = JSON.parse(this.responseText);

        console.log(response.type);

        if (response.type === 'success') {
            console.log("success")
        } else {
            console.log("failed")
        }

    }else{
        console.log("error");
    }
}
xhr.send();
Nov
20
3 weeks ago
Activity icon

Started a new Conversation JS XHR Response Type Undefined

Hi, I'm trying to do a XHR request to display my data dynamically through a select option. I have setup up the XHR url to my controller method where it would return a json response however I'm getting a undefined response type.

Script

document.getElementById('status').addEventListener('change', e => { 

    //Get Selected Value From Options
    const selectedOptions = e.target.options[e.target.selectedIndex].value

    const xhr = new XMLHttpRequest();

    xhr.open('GET', '{!!URL:: to('filterStatus')!!}', true);

    xhr.onload = function () {
        if (this.status === 200) {
            const response = JSON.parse(this.responseText);

            console.log(response.type);

            if (response.type === 'success') {
                console.log("success")
            } else {
                console.log("failed")
            }

        }else{
            console.log("error");
        }
    }
    xhr.send();
});

filterStatus method

public function filterStatus(Request $request){
   
    $report = Report::all();

    return response()->json($report);
}

Route

Route::get('filterStatus', '[email protected]');

As you can see above, I did not pass my selectedOptions to the request. Which brings me to my second question is how do i pass that value to the request so that instead of getting all my Report, I can filter out based on the request? I have done this with JQuery AJAX but I'm attempting to try use vanilla js for this. Anyone able to help

Aug
19
3 months ago
Activity icon

Started a new Conversation Laravel 5.8 Mix: How To Compile All .scss Files In The Folder Without Specifying Each File

Hi everyone, I'm trying to import some external .scss files onto my project but there are too many to list. Is there a way to compile all the .scss files in the folder without having to specify every individual file. I'm trying to achieve something similar to the code below but unfortunately it is not working. Any ideas how can this be done?

mix.sass('resources/sass/*.scss', 'public/css');