Linked Questions
39 questions linked to/from How do you JSON.stringify an ES6 Map?
2
votes
3
answers
2k
views
Map initialization in typescript [duplicate]
I am trying to initialize below Map in typescript. When I print it, it seems to be empty.
let map: Map<string, object> = new Map<string, object> ([
[
"api/service/method&...
1
vote
2
answers
1k
views
How to stringify new Map()? [duplicate]
I have the following code:
const x = new Map([['key', 'value']])
Now, I want to stringify this. I used the following:
JSON.stringify(x)
...which gave me an empty object.
How do you actually ...
0
votes
1
answer
806
views
Is it possible to return a map from NodeJS request? [duplicate]
I'm trying to return an array and a map from my NodeJS request.
let returnData = {
credits: [],
details: new Map()
}
const data = req.body.data || req.body;
const credits = await CheckRegister....
0
votes
1
answer
775
views
Save TypeScript class object to Firestore using the Node.js Admin SDK [duplicate]
I am trying to set data in a Firestore document from an object of a TypeScript class -
class Quest {
id: number = Date.now();
index: number = 0;
quest: string[];
options = new Map&...
1
vote
0
answers
185
views
Angular HTTP POST - pass a Map structure in the payload [duplicate]
I'm asking myself if is possible to pass a classic Map structrure (javascript/typescript) via http post request.
When I try to do it, I see in browser console (network section) that the request ...
0
votes
0
answers
173
views
Why is this map empty after array.reduce [duplicate]
Why does this map print empty? I'd expect it to be populated from the array? I'm probably missing something small.
let numbers = [1, 2, 3];
let numberMap = numbers.reduce((map, obj) => {
...
0
votes
1
answer
171
views
How to convert an Object with Map to JSON Object [duplicate]
I am trying to convert an object containing map to json using JSON.stringify().
But after the conversion map data gets cleared.
How do i solve this issue?
frieghtChargesJSon:string; //declared ...
0
votes
0
answers
164
views
Why javascript Map() object is empty when passed from frontend? [duplicate]
I use this code when make a request to server. Inside request function i do this:
const menu = this.props.location.state.menuItemDishesMap; //get Map() value from props
const order = {
person: { id:...
1
vote
0
answers
114
views
Typescript Generic Map type not able to set KVP [duplicate]
I am trying to create a generic Map in typescript but no KVPs are getting set in the map.
class type1 {
public prop1: string;
}
var t1: type1 = {
prop1: '1'
};
var t2: type1 = {
prop1: '...
0
votes
0
answers
52
views
Typescript Map doesn't receive entries from set() [duplicate]
i am trying to use a Map to store some data in a class. On creation I am initializing the Map with initial data. The Problem is that after the initBoard() function the Map is still empty.
The Map ...
0
votes
0
answers
50
views
How to deep stringify the following object [duplicate]
I have the following object
const resultAnalytic: ExportAnalyticsData = {
document: {
ownerIsExporting: false,
hasBeenExported: false
},
...
0
votes
0
answers
33
views
Empty object instead of Map<string, string[]> sent via httpClient.post [duplicate]
I want to send Map<string, string[]> as a field of DO sent via http.post(). Method that calls post looks like that: this.http.post<Something>('/something', somethingDO);
DO looks basically ...
0
votes
0
answers
31
views
How do I write a Map to a text file in JavaScript? [duplicate]
I am trying to write the contents of a Map to a text file, but am getting an error. Here is my code:
const dictionary = new Map()
dictionary['foo'] = 10
dictionary['test'] = 5
dictionary['sample'] = 7
...
0
votes
0
answers
31
views
Promise.all return value [duplicate]
I'm trying to build an array of objects where some of the fields need remote data. It all works with awaits inside the loop but I'm interested in optimising this. I wrote the following proof-of-...
0
votes
0
answers
25
views
ES6 Map autoconverted to {}? [duplicate]
In my React Native + TypeScript app, I've defined a bunch of types as follows:
export type Streak = {
...
marked: Map<number, string>
};
export type Habit = {
...
...
streak: ...