Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Boosh!
Apr 12, 2002
Oven Wrangler
I'm grabbing data from my WordPress JSON feed and it's working except the last bit where I'm assigning the image path. Specifically:

code:
imgPath: data.posts[g].attachments.url
code:
$.ajax({
	url: 'http://mysite.com/?json=1&count=8',
	dataType: 'jsonp',
	async : false,
	success: function (data) {
		var entryArr = [];
		for (g = 0; g < sequenceArr.length; g++) {
                	entryArr.push({
                        title: data.posts[g].title,
                        link: data.posts[g].url,
                        caption: data.posts[g].content,
                        imgPath: data.posts[g].attachments.url
		 });
	}
});
The only difference is that value is nested one extra level.


EDIT:

Got it.

code:
imgPath: data.posts[g].attachments[0].url

Boosh! fucked around with this message at 17:30 on Mar 7, 2016

Adbot
ADBOT LOVES YOU

Boosh!
Apr 12, 2002
Oven Wrangler
Is there a jquery event or some method, that's the opposite of .one()? I have a function that loads content, then tiles them, masonry style. I would rather not reload the content of course.

I suppose I could just add a counter or something but I'm open to something a bit more elegant.

Boosh! fucked around with this message at 14:47 on Aug 8, 2016

Boosh!
Apr 12, 2002
Oven Wrangler
Ahhh simple enough, thanks fellas :waycool:

Boosh!
Apr 12, 2002
Oven Wrangler
I am moving my Contentful API calls from my React app to my Express API, merely wrapping my Contentful calls in routes:

code:
app.get('/getAll, (req, res) => {

    client.getEntries({
        content_type: 'presentation',
	limit: 30,
        skip: 0,
    })
    .then((response) => {
	console.log(response)
        res.json(response)
    })

})
With the limit set to 30 it works, but if I bump the limit to 60 or so I get an ERR_EMPTY_RESPONSE error message in my console (doesn't work in Postman either). This was working perfectly fine in my React app but once I moved the calls to Express I started to have this problem. The payload is pretty small, about 60kb and I am able to log it right before sending it. Any idea why this is happening?

EDIT: Seems like any response over 60kb is having this issue vs limit size.

Boosh! fucked around with this message at 14:54 on May 7, 2020

Boosh!
Apr 12, 2002
Oven Wrangler

Doom Mathematic posted:

Your code is conspicuously missing a handler for when the promise chain rejects. My suspicion is that either client.getEntries(...) is failing, or response can't be converted to JSON for some reason. I suggest adding a .catch block to properly handle the error case - this may make it easier to diagnose the issue.

Sorry I just left it off here, I have in the code. The getEntries call hasn't failed yet; I am able to console log the response every time from my API:



Seems like once the getEntries payload is over 60k (it works for anything under) it sends nothing. On the client side, I'm getting this error: GET https://api.mysite.com/getAll net::ERR_EMPTY_RESPONSE

I can work around this creating a new, trim object with only the data I need, but I'm still curious as to why this is happening.

Boosh! fucked around with this message at 21:57 on May 7, 2020

Boosh!
Apr 12, 2002
Oven Wrangler

necrotic posted:

Logging to console is not the same as serializing to json. Try to JSON.stringify it and see if that fails.

That failed too. I copied the JSON.stringified of it and just tried to res.send it with all the Contentful logic removed and still nothing.

code:
app.get('/getAllReports', (req, res) => {
	res.send(`[{"sys":{"space":{"sys":{"type":"Link","linkTyp........(50-60kb worth of text)........]`)
})
Trimming that string in half worked though. I am not finding anything on send limits, and 60ish kb is nothing.

Boosh!
Apr 12, 2002
Oven Wrangler
Thanks guys. I’ll try those out and report back.

Adbot
ADBOT LOVES YOU

Boosh!
Apr 12, 2002
Oven Wrangler
If you don't need a page for every dynamic route you can use catch-all segments: https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes

You can also ditch the static folders (category, preset, , slot and card). Your route would be something like: /<category id>/<preset id>/<slot id>/<card id>

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply