error2013
asked on
Error - Expected 2 Arguments but got 0
I am having the following error with this code:
Error: Expected 2 Arguments but got 0
How can I fix this?
insertData(fname, lname) {
const body = JSON.stringify({firstName: fname, lastName: lname});
}
Error: Expected 2 Arguments but got 0
How can I fix this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>Still getting the same error:
you're writing something different.
most likely the return part is error
you're writing something different.
most likely the return part is error
use browser's Inspect tool to verify the exact errors
ASKER
The errors are pointing to this line:
And only appeared when I added fname and lname to the function
const body = JSON.stringify({'firstName': fname, 'lastName': lname});
And only appeared when I added fname and lname to the function
Where do you exactly get the error? in the JSON line, or when calling the function?
In the latter case look where this function is called and if always with two parameters
In the latter case look where this function is called and if always with two parameters
ASKER
ref: 'use browser's Inspect tool to verify the exact errors'
I'm using typescript and code won't compile so I won't get to the browser till I can compile it.
I'm using typescript and code won't compile so I won't get to the browser till I can compile it.
Are both fname and lname defined?
so tried exactly what I posted previously?
use var and " instead of const and '
use var and " instead of const and '
ASKER
I had to add the parameters to another file. Your change worked fine :)
ASKER
Open in new window