createAd
createAd(
id: string,
options: NitroAdOptions,
): NitroAd | Promise<NitroAd> | Promise<NitroAd[]> | nullCreates an ad placement.
Remarks
The id used for a placement must be unique on the page it appears, and should be a stable identifier for the ad placement. Randomized values should not be used for id.
Parameters
id(string) — The id for the placement. For most placement types, this should be the id of a div that the ad will fill.options(NitroAdOptions) — The options object containing settings for the placement.
Returns
NitroAd| Promise<NitroAd> | Promise<NitroAd[]> | null— Depending on loading state, this may return a promise or an object.
Example
CODE
// basic usage
window.nitroAds.createAd('banner-1', {
sizes: [[728, 90]],
});CODE
// you can wrap with Promise.resolve to handle case where return may be a promise or not
Promise.resolve(window.nitroAds.createAd('banner-1', {})).then((ad) => {
// now save ad object for later use
});CODE
// you can also just use await in an async function
let ad = await window.nitroAds.createAd('banner-1', {});