The error message seems pretty straightforward to me. You are passing a string “Testing me” to something that is expecting a number instead, so it pukes.
Incidentally, you do not need to define that header object or manually call JSON.stringify(). Http handles both of those things.
Why would “location” expect a number? Is it because the database already has a old record with the location field being a number? I will try deleting all records and rerun with “testing me”.
I use stringify and header because I am following a tutorial. I shall read more on this subject. The JSON conversation back and forth is driving me crazy
Thank you @rapropos
The back-end is like this. No wonder!!!.. I was scratching my head all day long …
var Treasure = mongoose.model('Treasure', {
title: String,
description: String,
location: Number
});
I was reading things on http, it says http only handles plain text, and JSON.stringify is used to convert an object to strings. If I don’t do manual JSON.stringify() call, what is the right way to do it?
There’s a difference between http and Http. If you’re using the Angular Http provider, it’s best to read that official documentation. The web is full of Ionic tutorials that are either out of date or just not very good.