Giter Club home page Giter Club logo

Comments (8)

kmacdonaO avatar kmacdonaO commented on July 23, 2024 1

Can you show your code that is invoking the method on the delivery client?

from content-management-sdk.

kmacdonaO avatar kmacdonaO commented on July 23, 2024

@tcaruth (Sorry for not seeing this earlier)

When you say you're using the SDK through the OCM Toolkit, can you explain what you're calling on the toolkit, or are you directly calling the SDK that is bundled with the toolkit?

The SDK has a beforeSend function which is usually how I'd recommend customizing any requests you need to make but I'm not sure whether you have direct access to this as I'm not that familiar with the toolkit.

from content-management-sdk.

tcaruth avatar tcaruth commented on July 23, 2024

The OCM toolkit has the sdk bundled with it and uses that instead of pulling it from npm
https://github.com/oracle/content-and-experience-toolkit/blob/master/sites/test/server/npm/contentSDK.js

An OCM component gets passed the SitesSDK (and other things) into it's constructor that I can use to get access to a contentSDK that has the content delivery or content preview client already instantiated. This means I don't need to set a channel or context up for it, it's just available for use immediately.

@BrianJCheyne may be able to provide more insight, I'm only semi-familiar with how the toolkit forwards requests to OCM

from content-management-sdk.

tcaruth avatar tcaruth commented on July 23, 2024

Here'/s the component running on the page with the code below
https://rcsocedev-rcsmobile.ocecdn.oraclecloud.com/site/Cafe-Supremo/contentsdk-demo.html

// The Custom Component class will be the "default" export from the module
export default class {
	constructor(args) {
		// get the OCM environment resources
		this.sitesSDK = args.SitesSDK
		this.contentClient = this.sitesSDK.getProperty('contentClient')
	}

	async render(container) {
		this.container = container
		console.log({ contentClient: this.contentClient }) // this is the delivery or preview client, depending on SCSRenderAPI.getRenderMode()
		let promoItems = await this.contentClient.queryItems({
			q: 'type eq "Promo"'
		})
		let channelToken = this.contentClient.getInfo().channelToken
		let graphItems = await this.contentClient.graphql({
			query: `{
				getPromoCollection(channelToken:"${channelToken}") {
					items {
						id
						name
						updatedDate
						}
					}
				}
			`})
		console.log({ promoItems, graphItems })
		container.innerHTML = `<pre>${JSON.stringify(graphItems, null, 4)}</pre>`
	}
}

from content-management-sdk.

kmacdonaO avatar kmacdonaO commented on July 23, 2024

Is your problem that the contentClient does not have a channelToken, or what is it that is missing? A channelToken can be given as you are in the graphQL query, or it can be added as an HTTP header (e.g. via a beforeSend added to the API call).

from content-management-sdk.

tcaruth avatar tcaruth commented on July 23, 2024

As I understand it, the toolkit acts as a passthrough, or proxy. It takes calls to OCM's content APIs on localhost and points them at the server specified in the command cec develop -s targetServer.

When I tried using the contentSDK.graphql locally I was recieving an error stating I the channel token wasn't defined. I tested and found that to get a response, I had to provide channelToken either as a header or query parameter to get a response through the toolkit proxy. I can get on a Zoom and demonstrate if you like

I could take the provided delivery/preview client passed into my component's constructor, read it's properties and call createDeliveryClient again with a beforeSend, but that seems convoluted to me.

I think this ticket is more about how OCM and the toolkit passes the contentSDK to our components. I could file a ticket over there if it seems more appropriate.

from content-management-sdk.

kmacdonaO avatar kmacdonaO commented on July 23, 2024

@tcaruth Could you contact me via the email on my profile and we can set up a zoom?

from content-management-sdk.

kmacdonaO avatar kmacdonaO commented on July 23, 2024

As per meeting, there doesn't appear to be an issue with this SDK

from content-management-sdk.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.