This is in Google Script Editor. I've done a lot of searching but for some reason I can't find any information about a simple thing such as appending to an object.
I have an object like this:
var get_options = {
'method': 'get',
'muteHttpExceptions': true,
};
How would I go about appending to that object?
I want to add 'authorization': 'token',
to that object so the object will look like this:
var get_options = {
'method': 'get',
'muteHttpExceptions': true,
'authorization': 'token',
};
Please help! Thank you in advance.
Google App Script (GAS) uses javascript platform. So whenever you have some basic coding syntax you want to look up, refer to javascript documentation
To answer your question in brief,to add key pair value to get_options you would do the following
var get_options = {
'method': 'get',
'muteHttpExceptions': true,
};
get_options.authorization = “token”
//or
get_options["authorization"] = “token”
More detailed explanation you can be found in this SO post